Bugfix geo-coordinate-parser
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/* eslint-disable */
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
/**http://wiki.openstreetmap.org/wiki/Zoom_levels*/
|
||||
|
||||
var metersPerPixel = function (latitude, zoomLevel) {
|
||||
var earthCircumference = 40075017;
|
||||
var latitudeRadians = latitude * (Math.PI / 180);
|
||||
return earthCircumference * Math.cos(latitudeRadians) / Math.pow(2, zoomLevel + 8);
|
||||
};
|
||||
|
||||
var pixelValue = function (latitude, meters, zoomLevel) {
|
||||
return meters / metersPerPixel(latitude, zoomLevel);
|
||||
};
|
||||
|
||||
|
||||
function stripSVG(fName) {
|
||||
var rx = /<\s*svg[^>]*>([\s\S]*)<\s*\/svg[^>]*>/gm;
|
||||
var svg = fs.readFileSync(path.join(__static, '/', fName), 'utf8');
|
||||
var svg2 = rx.exec(svg);
|
||||
return svg2[0];
|
||||
}
|
||||
|
||||
const airLinerSVGs = {
|
||||
A: stripSVG('FGA_ACT_A_GA.svg'),
|
||||
B: stripSVG('FGA_ACT_B_PROP.svg'),
|
||||
C: stripSVG('FGA_ACT_C.svg'),
|
||||
D: stripSVG('FGA_ACT_D.svg'),
|
||||
E: stripSVG('FGA_ACT_E.svg'),
|
||||
F: stripSVG('FGA_ACT_F.svg')
|
||||
};
|
||||
|
||||
L.ParkingAircraftMarker = L.Marker.extend({
|
||||
options: {
|
||||
zIndexOffset: 10000,
|
||||
},
|
||||
|
||||
initialize: function (latlng, options) {
|
||||
L.Marker.prototype.initialize(latlng, options);
|
||||
L.Util.setOptions(this, options);
|
||||
this.heading = options.heading;
|
||||
this.updateIcon();
|
||||
|
||||
this.isDragging = false;
|
||||
|
||||
},
|
||||
updateProperties: function(properties) {
|
||||
this.heading = properties.heading;
|
||||
this.updateIcon();
|
||||
},
|
||||
updateIcon : function() {
|
||||
if(this._map !== undefined && this._map !== null) {
|
||||
var metersPP = metersPerPixel(this._map.getCenter().lat, this._map.getZoom());
|
||||
console.log(metersPP);
|
||||
var scale = 0.07 / metersPP;
|
||||
this.setIcon(L.divIcon({
|
||||
iconSize: null,
|
||||
className: 'aircraft-marker-icon',
|
||||
html: `<div style=\'transform: translateX(-10px) translateY(-10px); height: 20px; width: 20px; border: 1px red\'>${airLinerSVG}</div>`,
|
||||
}));
|
||||
this.getElement().children.item(0).children.item(0).style = `transform: translateX(-200px) translateY(-200px) scale(${scale},${scale}) rotate(${(this.heading)-45}deg)`;
|
||||
}
|
||||
else {
|
||||
this.setIcon(L.divIcon({
|
||||
iconSize: null,
|
||||
className: 'aircraft-marker-icon',
|
||||
html: `<div style=\'transform: rotate(${this.heading}deg) scale(0.001,0.001) \'>${airLinerSVG}</div>`,
|
||||
}));
|
||||
}
|
||||
},
|
||||
onAdd : function(map) {
|
||||
var metersPP = metersPerPixel(map.getCenter().lat, map.getZoom());
|
||||
console.log(metersPP);
|
||||
console.log(this);
|
||||
this.updateIcon();
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
//Builds a marker for a ai or multiplayer aircraft
|
||||
module.exports.default = function (latlng, options) {
|
||||
return new L.ParkingAircraftMarker(latlng, options);
|
||||
}
|
||||
|
||||
/*
|
||||
var l1 = feature.properties.callsign,
|
||||
l2 = feature.properties.heading + 'T ' + feature.properties.speed + 'KTAS ' +
|
||||
formatFL(feature.geometry.coordinates[2]),
|
||||
l3 = feature.properties.departureAirportId + ' -> ' + feature.properties.arrivalAirportId;
|
||||
|
||||
*/
|
||||
@@ -28,15 +28,6 @@ function addFrequencies (type, value) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack to avoid https://github.com/ianengelbrecht/geo-coordinates-parser/issues/1
|
||||
* @param {*} coordinate
|
||||
*/
|
||||
|
||||
function cleanCoord(coordinate) {
|
||||
return coordinate.replace('0.000', '0.001')
|
||||
}
|
||||
|
||||
exports.addFeature = function (feature) {
|
||||
featureLookup[feature.id] = new Array();
|
||||
}
|
||||
@@ -125,10 +116,10 @@ exports.readGroundnetXML = function (fDir, icao, force) {
|
||||
//attrs.lat
|
||||
//console.log(n.attr('lat') + " " + n.attr('lon'));
|
||||
try {
|
||||
var latlon = convert(cleanCoord(n.attr('lat')) + " " + cleanCoord(n.attr('lon')));
|
||||
var latlon = convert(n.attr('lat') + " " + n.attr('lon'));
|
||||
} catch (error) {
|
||||
console.warn(n.attr('lat') + " " + n.attr('lon'));
|
||||
convert(cleanCoord(n.attr('lat')) + " " + cleanCoord(n.attr('lon')));
|
||||
convert(n.attr('lat') + " " + n.attr('lon'));
|
||||
}
|
||||
//console.log(latlon.decimalLatitude);
|
||||
|
||||
@@ -181,8 +172,8 @@ exports.readGroundnetXML = function (fDir, icao, force) {
|
||||
});
|
||||
}
|
||||
if (!bidirectional) {
|
||||
var beginlatlon = convert(cleanCoord(beginNode.attr('lat')) + " " + cleanCoord(beginNode.attr('lon')));
|
||||
var endlatlon = convert(cleanCoord(endNode.attr('lat')) + " " + cleanCoord(endNode.attr('lon')));
|
||||
var beginlatlon = convert(beginNode.attr('lat') + " " + beginNode.attr('lon'));
|
||||
var endlatlon = convert(endNode.attr('lat') + " " + endNode.attr('lon'));
|
||||
var polyline = new L.Polyline([[beginlatlon.decimalLatitude, beginlatlon.decimalLongitude], [endlatlon.decimalLatitude, endlatlon.decimalLongitude]], { attributes: {} }).addTo(layerGroup);
|
||||
extendTaxiSegment(polyline);
|
||||
polyline.addListeners();
|
||||
|
||||
@@ -26,7 +26,7 @@ function stripSVG(fName) {
|
||||
const airLinerSVG = stripSVG('Airplane_silhouette.svg');
|
||||
const gaSVG = stripSVG('Black_aircraft_icon.svg');
|
||||
|
||||
L.AircraftMarker = L.Marker.extend({
|
||||
L.ParkingAircraftMarker = L.Marker.extend({
|
||||
options: {
|
||||
zIndexOffset: 10000,
|
||||
},
|
||||
@@ -75,7 +75,7 @@ L.AircraftMarker = L.Marker.extend({
|
||||
|
||||
//Builds a marker for a ai or multiplayer aircraft
|
||||
module.exports.default = function (latlng, options) {
|
||||
return new L.AircraftMarker(latlng, options);
|
||||
return new L.ParkingAircraftMarker(latlng, options);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user