show local flights (departure == arrival) as points

This commit is contained in:
Louis 2024-04-19 12:05:40 +02:00
parent 07c9e50a9f
commit e48882bf49

View file

@ -96,19 +96,31 @@
const toLongitude = parseFloat(toAirport.longitude); const toLongitude = parseFloat(toAirport.longitude);
const toLatitude = parseFloat(toAirport.latitude); const toLatitude = parseFloat(toAirport.latitude);
// if from == to, draw a point
var geometry;
if(fromAirport == toAirport) {
geometry = {
type: 'Point',
coordinates: [fromLongitude, fromLatitude]
};
}
else {
geometry = {
type: 'LineString',
coordinates: [
[fromLongitude, fromLatitude],
[toLongitude, toLatitude]
]
};
}
return { return {
type: 'Feature', type: 'Feature',
properties: { properties: {
from, from,
to to
}, },
geometry: { geometry: geometry
type: 'LineString',
coordinates: [
[fromLongitude, fromLatitude],
[toLongitude, toLatitude]
]
}
}; };
}); });
@ -129,10 +141,21 @@
'line-cap': 'round' 'line-cap': 'round'
}, },
paint: { paint: {
'line-color': '#bd34eb', 'line-color': '#ce42f5',
'line-width': 4 'line-width': 2
} }
}); });
map.addLayer({
id: 'points',
type: 'circle',
source: 'routes',
paint: {
'circle-radius': 5,
'circle-color': '#f00'
},
filter: ['==', '$type', 'Point']
});
} }
function updateMap(csvData) { function updateMap(csvData) {