This commit is contained in:
parent
00132e46fb
commit
7c8cc0e705
@ -41,12 +41,12 @@ function bezier(line, icao, layerGroup, currentFeature) {
|
||||
var startPoint = [Number(previous[0]), Number(previous[1])];
|
||||
var endPoint = [Number(line[1]), Number(line[2])];
|
||||
|
||||
if(module.exports.debug) {
|
||||
L.polyline([startPoint, endPoint], { color: 'fuchsia' }).addTo(layerGroup);
|
||||
var marker = new L.marker(endPoint, { title: 'endpoint', color: 'fuchsia' });
|
||||
marker.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), { className: "my-label", offset: [0, 0] });
|
||||
marker.addTo(layerGroup);
|
||||
}
|
||||
if (module.exports.debug) {
|
||||
L.polyline([startPoint, endPoint], { color: 'fuchsia' }).addTo(layerGroup);
|
||||
var marker = new L.marker(endPoint, { title: 'endpoint', color: 'fuchsia' });
|
||||
marker.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), { className: "my-label", offset: [0, 0] });
|
||||
marker.addTo(layerGroup);
|
||||
}
|
||||
|
||||
var control = [Number(line[3]), Number(line[4])];
|
||||
if (!isNaN(control[0]) && control[0] !== undefined && !isNaN(control[1]) && control[1] !== undefined) {
|
||||
@ -71,7 +71,7 @@ function bezier(line, icao, layerGroup, currentFeature) {
|
||||
L.polyline([startPoint, controlReflected, endPoint], { color: 'purple' }).addTo(layerGroup);
|
||||
|
||||
var marker = new L.marker(controlReflected, { title: 'control First' });
|
||||
marker.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), {className: "my-label", offset: [0, 0] });
|
||||
marker.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), { className: "my-label", offset: [0, 0] });
|
||||
marker.addTo(layerGroup);
|
||||
}
|
||||
points = deCasteljau([
|
||||
@ -82,11 +82,11 @@ function bezier(line, icao, layerGroup, currentFeature) {
|
||||
if (module.exports.debug) {
|
||||
L.polyline([startPoint, exports.bezierPoint, controlReflected, endPoint], { color: 'purple' }).addTo(layerGroup);
|
||||
var marker = new L.marker(exports.bezierPoint, { title: 'exports.bezierPoint' }).addTo(layerGroup);
|
||||
marker.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), {className: "my-label", offset: [0, 10] });
|
||||
marker.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), { className: "my-label", offset: [0, 10] });
|
||||
marker.addTo(layerGroup);
|
||||
|
||||
var marker1 = new L.marker(controlReflected, { title: 'controlReflected' }).addTo(layerGroup);
|
||||
marker1.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), {className: "my-label", offset: [0, -10] });
|
||||
marker1.bindTooltip(String(currentFeature.slice(-1)[0].length + ' ' + line), { className: "my-label", offset: [0, -10] });
|
||||
marker1.addTo(layerGroup);
|
||||
|
||||
}
|
||||
@ -276,36 +276,47 @@ module.exports.readPavement = function (f, icao, cb) {
|
||||
|
||||
store.default.dispatch('setPavementLoaded', false);
|
||||
|
||||
lineReader.createInterface({
|
||||
input: fs.createReadStream(f).pipe(zlib.createGunzip())
|
||||
}).on('line', function (line) {
|
||||
try {
|
||||
var fields = line.split(/[ ]+/);
|
||||
// var fields = line.match('([0-9]+)');
|
||||
if (fields == null)
|
||||
return;
|
||||
var scanMethod = scanMethods[fields[0]];
|
||||
if (scanMethod != null) {
|
||||
currentFeature = scanMethod(fields, icao, pavementLayerGroup, currentFeature);
|
||||
}
|
||||
else {
|
||||
if (fields[0] == '99') {
|
||||
lineReader.close();
|
||||
if (!fs.existsSync(f)) {
|
||||
store.default.dispatch('setPavementLoaded', true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
fs.accessSync(f, fs.constants.R_OK);
|
||||
lineReader.createInterface({
|
||||
input: fs.createReadStream(f).pipe(zlib.createGunzip())
|
||||
}).on('line', function (line) {
|
||||
try {
|
||||
var fields = line.split(/[ ]+/);
|
||||
// var fields = line.match('([0-9]+)');
|
||||
if (fields == null)
|
||||
return;
|
||||
var scanMethod = scanMethods[fields[0]];
|
||||
if (scanMethod != null) {
|
||||
currentFeature = scanMethod(fields, icao, pavementLayerGroup, currentFeature);
|
||||
}
|
||||
// console.log('Ignored:', line);
|
||||
else {
|
||||
if (fields[0] == '99') {
|
||||
lineReader.close();
|
||||
}
|
||||
// console.log('Ignored:', line);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error reading : ' + line + error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error reading : ' + line + error);
|
||||
}
|
||||
}).on('error', function (err) {
|
||||
}).on('error', function (err) {
|
||||
store.default.dispatch('setPavementLoaded', true);
|
||||
console.error(err);
|
||||
lr.close();
|
||||
}).on('close', function () {
|
||||
store.default.dispatch('setPavementLoaded', true);
|
||||
console.log("End");
|
||||
cb(pavementLayerGroup);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('no access!');
|
||||
store.default.dispatch('setPavementLoaded', true);
|
||||
console.error(err);
|
||||
lr.close();
|
||||
}).on('close', function () {
|
||||
store.default.dispatch('setPavementLoaded', true);
|
||||
console.log("End");
|
||||
cb(pavementLayerGroup);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.debug = false;
|
||||
@ -328,24 +339,24 @@ var scanMethods = {
|
||||
// APTDAT 715 Segment
|
||||
10: (line, icao, layerGroup) => {
|
||||
if (module.exports.isScanning) {
|
||||
var pointMiddle = new LatLonEllipsoidal(Number(line[1]), Number(line[2]));
|
||||
var point1 = pointMiddle.destinationPoint(line[5]/6.562, line[4]);
|
||||
var point2 = pointMiddle.destinationPoint(line[5]/6.562, line[4]-180);
|
||||
var pointMiddle = new LatLonEllipsoidal(Number(line[1]), Number(line[2]));
|
||||
var point1 = pointMiddle.destinationPoint(line[5] / 6.562, line[4]);
|
||||
var point2 = pointMiddle.destinationPoint(line[5] / 6.562, line[4] - 180);
|
||||
|
||||
var runwayPoints = [];
|
||||
var runwayPoints = [];
|
||||
|
||||
var bearing = point1.initialBearingTo(point2);
|
||||
// Width in ft
|
||||
var runwayWidth = Number(line[8])/3.281;
|
||||
var bearing = point1.initialBearingTo(point2);
|
||||
// Width in ft
|
||||
var runwayWidth = Number(line[8]) / 3.281;
|
||||
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
|
||||
var runwayPoly = buildTaxiwayPoly(runwayPoints);
|
||||
runwayPoly.addTo(layerGroup);
|
||||
}
|
||||
var runwayPoly = buildTaxiwayPoly(runwayPoints);
|
||||
runwayPoly.addTo(layerGroup);
|
||||
}
|
||||
},
|
||||
// Runway
|
||||
100: (line, icao, layerGroup) => {
|
||||
@ -369,19 +380,19 @@ var scanMethods = {
|
||||
runwayPoly.addTo(layerGroup);
|
||||
|
||||
var displacedEnd1 = point1.destinationPoint(Number(line[20]), bearing)
|
||||
var displacedEnd2 = point2.destinationPoint(Number(line[20]), bearing-180)
|
||||
var displacedEnd2 = point2.destinationPoint(Number(line[20]), bearing - 180)
|
||||
|
||||
var runwayLine = new L.Polyline([displacedEnd1, displacedEnd2]);
|
||||
runwayLine.setStyle({ color: 'yellow', stroke: true, dashArray: [50,50] });
|
||||
runwayLine.setStyle({ color: 'yellow', stroke: true, dashArray: [50, 50] });
|
||||
runwayLine.addTo(layerGroup);
|
||||
|
||||
var t1 = new L.Polyline([displacedEnd1.destinationPoint(runwayWidth / 2, (bearing - 90)),
|
||||
displacedEnd1.destinationPoint(runwayWidth / 2, (bearing + 90))]);
|
||||
displacedEnd1.destinationPoint(runwayWidth / 2, (bearing + 90))]);
|
||||
t1.setStyle({ color: 'yellow' });
|
||||
t1.addTo(layerGroup);
|
||||
|
||||
var t2 = new L.Polyline([displacedEnd2.destinationPoint(runwayWidth / 2, (bearing - 90)),
|
||||
displacedEnd2.destinationPoint(runwayWidth / 2, (bearing + 90))]);
|
||||
displacedEnd2.destinationPoint(runwayWidth / 2, (bearing + 90))]);
|
||||
t2.setStyle({ color: 'yellow' });
|
||||
t2.addTo(layerGroup);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user