Fix gaps in IDs
This commit is contained in:
parent
8732819261
commit
bf56736ab9
@ -56,6 +56,7 @@ exports.readGroundnetXML = function (fDir, icao, f) {
|
|||||||
try {
|
try {
|
||||||
store.default.dispatch('setGroundnetLoaded', false);
|
store.default.dispatch('setGroundnetLoaded', false);
|
||||||
var layerGroup = L.layerGroup();
|
var layerGroup = L.layerGroup();
|
||||||
|
layerGroup.minId = 9999999999;
|
||||||
layerGroup.maxId = 0;
|
layerGroup.maxId = 0;
|
||||||
|
|
||||||
if (f == null || (!fs.existsSync(f) ))
|
if (f == null || (!fs.existsSync(f) ))
|
||||||
@ -113,6 +114,7 @@ exports.readGroundnetXML = function (fDir, icao, f) {
|
|||||||
nodesLookup[n.attr('index')] = n;
|
nodesLookup[n.attr('index')] = n;
|
||||||
featureLookup[n.attr('index')] = new Array();
|
featureLookup[n.attr('index')] = new Array();
|
||||||
featureLookup[n.attr('index')].push(circle);
|
featureLookup[n.attr('index')].push(circle);
|
||||||
|
layerGroup.minId = Math.min(layerGroup.minId, Number(n.attr('index')))
|
||||||
layerGroup.maxId = Math.max(layerGroup.maxId, Number(n.attr('index')))
|
layerGroup.maxId = Math.max(layerGroup.maxId, Number(n.attr('index')))
|
||||||
features.push(circle);
|
features.push(circle);
|
||||||
}).sort();
|
}).sort();
|
||||||
@ -139,7 +141,9 @@ exports.readGroundnetXML = function (fDir, icao, f) {
|
|||||||
}
|
}
|
||||||
//console.log(latlon.decimalLatitude);
|
//console.log(latlon.decimalLatitude);
|
||||||
|
|
||||||
|
layerGroup.minId = Math.min(layerGroup.minId, Number(n.attr('index')))
|
||||||
layerGroup.maxId = Math.max(layerGroup.maxId, Number(n.attr('index')))
|
layerGroup.maxId = Math.max(layerGroup.maxId, Number(n.attr('index')))
|
||||||
|
console.debug(`Min Id : ${layerGroup.minId} Max Id : ${layerGroup.maxId} `);
|
||||||
|
|
||||||
nodesLookup[n.attr('index')] = n;
|
nodesLookup[n.attr('index')] = n;
|
||||||
if (n.attr('isOnRunway') === '1') {
|
if (n.attr('isOnRunway') === '1') {
|
||||||
|
@ -57,6 +57,12 @@ function walkPushbackRoute (index, walkedNodes, pushBackNodes) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} fDir The directory
|
||||||
|
* @param {*} icao
|
||||||
|
* @param {*} featureList
|
||||||
|
*/
|
||||||
|
|
||||||
exports.writeGroundnetXML = function (fDir, icao, featureList) {
|
exports.writeGroundnetXML = function (fDir, icao, featureList) {
|
||||||
try {
|
try {
|
||||||
@ -91,6 +97,8 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
|
|||||||
var parkings = featureList.map(mapParkings).filter(n => n);
|
var parkings = featureList.map(mapParkings).filter(n => n);
|
||||||
var runwayNodes = featureList.map(mapRunwayNodes).filter(n => n);
|
var runwayNodes = featureList.map(mapRunwayNodes).filter(n => n);
|
||||||
var holdNodes = featureList.map(mapHoldPoint).filter(n => n);
|
var holdNodes = featureList.map(mapHoldPoint).filter(n => n);
|
||||||
|
|
||||||
|
|
||||||
holdNodes.forEach(n => {
|
holdNodes.forEach(n => {
|
||||||
pushBackNodeLookup[n['@index']] = n;
|
pushBackNodeLookup[n['@index']] = n;
|
||||||
});
|
});
|
||||||
@ -189,6 +197,51 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
|
|||||||
|
|
||||||
var unicomList = store.default.state.Frequencies.items.filter(f => f.type === 'UNICOM').map(mapFrequency);
|
var unicomList = store.default.state.Frequencies.items.filter(f => f.type === 'UNICOM').map(mapFrequency);
|
||||||
|
|
||||||
|
|
||||||
|
var gapStart = -1;
|
||||||
|
var gapEnd = -1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
gapStart = -1;
|
||||||
|
gapEnd = -1;
|
||||||
|
var allIds = parkings.map(n => Number(n['@index']))
|
||||||
|
.concat(uniqueNodes.map(n => Number(n['@index'])))
|
||||||
|
.sort((a, b) => a - b);
|
||||||
|
|
||||||
|
allIds.forEach((element, index, array) => {
|
||||||
|
if (index > 0 && array[index-1] + 1 != element && gapStart == -1 ) {
|
||||||
|
gapStart = array[index-1];
|
||||||
|
gapEnd = element;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var gap = gapEnd - gapStart -1;
|
||||||
|
|
||||||
|
parkings = parkings.map(n => {
|
||||||
|
if (n['@index']>gapStart) {
|
||||||
|
n['@index'] = String(n['@index'] - gap);
|
||||||
|
}
|
||||||
|
if (n['@pushbackRoute']>gapStart) {
|
||||||
|
n['@pushbackRoute'] = String(n['@pushbackRoute'] - gap);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
});
|
||||||
|
uniqueNodes = uniqueNodes.map(n => {
|
||||||
|
if (n['@index']>gapStart) {
|
||||||
|
n['@index'] = String(n['@index'] - gap);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
});
|
||||||
|
arcList = arcList.map(n => {
|
||||||
|
if (n['@begin']>gapStart) {
|
||||||
|
n['@begin'] = String(n['@begin'] - gap);
|
||||||
|
}
|
||||||
|
if (n['@end']>gapStart) {
|
||||||
|
n['@end'] = String(n['@end'] - gap);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
});
|
||||||
|
} while( gapStart > 0 && gapEnd > 0);
|
||||||
|
|
||||||
var xmlObj = { groundnet: { version: 1, fgaversion: version, name: name,
|
var xmlObj = { groundnet: { version: 1, fgaversion: version, name: name,
|
||||||
'frequencies': { APPROACH: approachList, DEPARTURE: departureList, AWOS: awosList, CLEARANCE: clearanceList, GROUND: groundList, TOWER: towerList, UNICOM: unicomList },
|
'frequencies': { APPROACH: approachList, DEPARTURE: departureList, AWOS: awosList, CLEARANCE: clearanceList, GROUND: groundList, TOWER: towerList, UNICOM: unicomList },
|
||||||
parkingList: { Parking: parkings }, TaxiNodes: { node: uniqueNodes }, TaxiWaySegments: { arc: arcList } } };
|
parkingList: { Parking: parkings }, TaxiNodes: { node: uniqueNodes }, TaxiWaySegments: { arc: arcList } } };
|
||||||
|
Loading…
Reference in New Issue
Block a user