mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-07-31 07:57:28 +02:00
fix: render flight trails for all no-route aircraft instead of selected only
This commit is contained in:
@@ -824,35 +824,36 @@ const MaplibreViewer = ({ data, activeLayers, onEntityClick, flyToLocation, sele
|
|||||||
return { type: 'FeatureCollection', features };
|
return { type: 'FeatureCollection', features };
|
||||||
}, [selectedEntity, data, dynamicRoute]);
|
}, [selectedEntity, data, dynamicRoute]);
|
||||||
|
|
||||||
// Trail history GeoJSON: shows where an aircraft has been (from backend trail data)
|
// Trail history GeoJSON: render trails for ALL flights without a known route
|
||||||
const trailGeoJSON = useMemo(() => {
|
const trailGeoJSON = useMemo(() => {
|
||||||
if (!selectedEntity || !data) return null;
|
if (!data) return null;
|
||||||
|
const features: any[] = [];
|
||||||
let entity = null;
|
const allLists = [
|
||||||
if (selectedEntity.type === 'flight') entity = data?.commercial_flights?.[selectedEntity.id as number];
|
data.commercial_flights,
|
||||||
else if (selectedEntity.type === 'private_flight') entity = data?.private_flights?.[selectedEntity.id as number];
|
data.private_flights,
|
||||||
else if (selectedEntity.type === 'military_flight') entity = data?.military_flights?.[selectedEntity.id as number];
|
data.private_jets,
|
||||||
else if (selectedEntity.type === 'private_jet') entity = data?.private_jets?.[selectedEntity.id as number];
|
data.military_flights,
|
||||||
else if (selectedEntity.type === 'tracked_flight') entity = data?.tracked_flights?.[selectedEntity.id as number];
|
data.tracked_flights,
|
||||||
|
];
|
||||||
if (!entity || !entity.trail || entity.trail.length < 2) return null;
|
for (const list of allLists) {
|
||||||
|
if (!list) continue;
|
||||||
// trail points are [lat, lng, alt, timestamp] — convert to [lng, lat] for GeoJSON
|
for (const f of list) {
|
||||||
const coords = entity.trail.map((p: number[]) => [p[1], p[0]]);
|
if (!f.trail || f.trail.length < 2) continue;
|
||||||
// Append current position as the final point
|
// Only show trails for flights without a known route
|
||||||
if (entity.lat != null && entity.lng != null) {
|
if (f.origin_name && f.origin_name !== 'UNKNOWN') continue;
|
||||||
coords.push([entity.lng, entity.lat]);
|
if (!inView(f.lat, f.lng)) continue;
|
||||||
|
const coords = f.trail.map((p: number[]) => [p[1], p[0]]);
|
||||||
|
if (f.lat != null && f.lng != null) coords.push([f.lng, f.lat]);
|
||||||
|
features.push({
|
||||||
|
type: 'Feature',
|
||||||
|
properties: { type: 'trail' },
|
||||||
|
geometry: { type: 'LineString', coordinates: coords }
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (features.length === 0) return null;
|
||||||
return {
|
return { type: 'FeatureCollection', features };
|
||||||
type: 'FeatureCollection',
|
}, [data, inView]);
|
||||||
features: [{
|
|
||||||
type: 'Feature',
|
|
||||||
properties: { type: 'trail' },
|
|
||||||
geometry: { type: 'LineString', coordinates: coords }
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
}, [selectedEntity, data]);
|
|
||||||
|
|
||||||
const spreadAlerts = useMemo(() => {
|
const spreadAlerts = useMemo(() => {
|
||||||
if (!data?.news) return [];
|
if (!data?.news) return [];
|
||||||
|
|||||||
Reference in New Issue
Block a user