Add routes
This commit is contained in:
parent
55295b84aa
commit
afc45cc9cc
10 changed files with 241 additions and 21 deletions
|
|
@ -5,6 +5,7 @@
|
|||
import { distHaversine } from '../lib/mathutil.ts';
|
||||
|
||||
import { latestPredictionParsed } from '../lib/prediction.ts';
|
||||
import { latestTelemetryParsed } from '../lib/telemetry.ts';
|
||||
|
||||
/**
|
||||
* @type {L.Map}
|
||||
|
|
@ -147,6 +148,65 @@
|
|||
map.setView(launch.latlng, 8);
|
||||
};
|
||||
|
||||
const plotTelemetryTrack = (telemetry) => {
|
||||
console.log("Telemetry data parsed, creating map plot...");
|
||||
|
||||
// Clear existing map items
|
||||
if (marker) {
|
||||
map.eachLayer((layer) => {
|
||||
if (layer instanceof L.Marker || layer instanceof L.Polyline) {
|
||||
map.removeLayer(layer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create custom icons for telemetry markers
|
||||
const telemetryIcon = L.icon({
|
||||
iconUrl: 'marker-sm-red.png',
|
||||
iconSize: [10, 10],
|
||||
iconAnchor: [5, 5],
|
||||
});
|
||||
|
||||
const launchIcon = L.icon({
|
||||
iconUrl: 'target-blue.png',
|
||||
iconSize: [10, 10],
|
||||
iconAnchor: [5, 5],
|
||||
});
|
||||
|
||||
// Add markers to the map
|
||||
const launchMarker = L.marker(telemetry.launch.latlng, {
|
||||
title: `Launch (${telemetry.launch.latlng.lat.toFixed(4)}, ${telemetry.launch.latlng.lng.toFixed(4)}) at ${telemetry.launch.datetime.toUTCString()}`,
|
||||
icon: launchIcon,
|
||||
}).addTo(map);
|
||||
|
||||
// interface TelemetryPoint {
|
||||
// altitude: number;
|
||||
// datetime: string;
|
||||
// latitude: number;
|
||||
// longitude: number;
|
||||
// payload: string;
|
||||
// }
|
||||
|
||||
// Add telemetry markers to the map
|
||||
telemetry.datapoints.forEach((point) => {
|
||||
const telemetryMarker = L.marker([point.latitude, point.longitude], {
|
||||
title: `Telemetry (${point.latitude.toFixed(4)}, ${point.longitude.toFixed(4)}) at ${point.datetime}`,
|
||||
icon: telemetryIcon,
|
||||
}).addTo(map)
|
||||
.bindPopup(() => {
|
||||
return `
|
||||
<b>Telemetry Point</b><br>, Lat: ${point.latitude.toFixed(6)}<br>, Lon: ${point.longitude.toFixed(6)}<br>
|
||||
`;
|
||||
});
|
||||
});
|
||||
|
||||
// Add flight path polyline
|
||||
const pathPolyline = L.polyline(telemetry.flight_path, {
|
||||
weight: 3,
|
||||
color: "#000000",
|
||||
}).addTo(map);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<div class="map-container">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue