/usr/share/games/flightgear/Phi/topics/Map/NavdbLayer.js is in flightgear-phi 2016.4.2+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | (function(factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
define([
'leaflet','./MapIcons'
], factory);
} else {
// Browser globals
factory();
}
}(function(leaflet,MAP_ICON) {
leaflet.NavdbLayer = leaflet.GeoJSON.extend({
options : {
pointToLayer : function(feature, latlng) {
var options = {
title : feature.properties.id + ' (' + feature.properties.name + ')',
alt : feature.properties.id,
riseOnHover : true,
};
if (feature.properties.type == "airport") {
if (this._map && this._map.getZoom() >= 13) {
options.icon = MAP_ICON['arp'];
} else {
options.angle = feature.properties.longestRwyHeading_deg;
switch (feature.properties.longestRwySurface) {
case 'asphalt':
case 'concrete':
options.icon = MAP_ICON['airport-paved'];
break;
case 'unknown':
options.icon = MAP_ICON['airport-unknown'];
break;
default:
options.icon = MAP_ICON['airport-unpaved'];
break;
}
}
} else {
if (feature.properties.type in MAP_ICON) {
options.icon = MAP_ICON[feature.properties.type];
}
}
return new leaflet./*Rotated*/Marker(latlng, options);
},
onEachFeature : function(feature, layer) {
if (feature.properties) {
var popupString = '<div class="popup">';
for ( var k in feature.properties) {
var v = feature.properties[k];
popupString += k + ': ' + v + '<br />';
}
popupString += '</div>';
layer.bindPopup(popupString, {
maxHeight : 200
});
if( feature.properties.metar ) {
}
}
},
filter : function(feature) {
var zoom = (this._map && this._map.getZoom()) || 11;
switch (feature.properties.type) {
case 'airport':
if (zoom >= 10)
return true;
return feature.properties.longestRwyLength_m >= 2000;
break;
case 'NDB':
if (zoom >= 10)
return true;
if (zoom >= 8)
return feature.properties.range_nm >= 30;
return feature.properties.range_nm > 50;
}
return true;
},
style : function(feature) {
if (feature.properties.type == "ILS" || feature.properties.type == "localizer") {
return {
color : 'black',
weight : 2,
};
}
if (feature.properties.type == "airport") {
return {
color : 'black',
weight : 3,
fill : 'true',
fillColor : '#606060',
fillOpacity : 1.0,
lineJoin : 'bevel',
};
}
},
},
onAdd : function(map) {
leaflet.GeoJSON.prototype.onAdd.call(this, map);
this.dirty = true;
this.update(++this.updateId);
},
onRemove : function(map) {
this.updateId++;
leaflet.GeoJSON.prototype.onRemove.call(this, map);
},
stop : function() {
this.updateId++;
},
invalidate : function() {
this.dirty = true;
},
dirty : true,
updateId : 0,
update : function(id) {
var that = this;
if (this.updateId != id)
return;
if (this.dirty) {
this.dirty = false;
var bounds = this._map.getBounds();
// radius in NM
var radius = bounds.getSouthWest().distanceTo(bounds.getNorthEast()) / 3704;
if (radius > 250)
radius = 250;
if (radius < 10)
radius = 10;
var filter = "vor,ndb,airport";
if (radius < 60)
filter += ",ils,dme,loc,om,fix";
if (radius < 20)
filter += ",mm";
var center = this._map.getCenter();
var lat = center.lat;
var lon = center.lng;
var url = "/navdb?q=findWithinRange&type=" + filter + "&range=" + radius + "&lat=" + lat + "&lon=" + lon;
var jqxhr = $.get(url).done(function(data) {
if (that.updateId == id) {
that.clearLayers();
that.addData.call(that, data);
}
}).fail(function() {
that.updateId++;
alert('failed to load navdb data');
}).always(function() {
});
}
if (this.updateId == id) {
setTimeout(function() {
that.update(id)
}, 5000);
}
},
});
leaflet.navdbLayer = function(options) {
return new leaflet.NavdbLayer(null, options);
}
}));
|