fix elevation_gain_m null for modern Garmin FIT files; fix map flash
FIT parser: try enhanced_altitude before altitude. Barometric altimeters on modern Garmins (Edge 540, 840, etc.) write enhanced_altitude in record messages and total_ascent in lap messages. The old code read only altitude, producing null elevation_m per point → null elevation_gain_m at the activity root while laps had correct values from total_ascent. ActivityMap: use preview_coords (passed from ActivitySummary) to initialise the map at the activity's location on mount, eliminating the flash of world-view before the async detail JSON / bbox arrives.
This commit is contained in:
@@ -244,6 +244,7 @@
|
||||
{trackUrl}
|
||||
{timeseries}
|
||||
bbox={detail?.bbox ?? null}
|
||||
initialCoords={activity.preview_coords}
|
||||
accentColor={color}
|
||||
bind:hoveredIdx
|
||||
/>
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
export let trackUrl: string;
|
||||
export let timeseries: Timeseries | null = null;
|
||||
export let bbox: [number, number, number, number] | null = null;
|
||||
/** ~20 [lat, lon] preview coords from the activity summary — used to position
|
||||
* the map immediately on mount so there's no flash of world view before the
|
||||
* detail JSON loads and bbox arrives. */
|
||||
export let initialCoords: [number, number][] | null = null;
|
||||
export let accentColor: string = '#00c8ff';
|
||||
export let hoveredIdx: number | null = null;
|
||||
|
||||
@@ -19,11 +23,25 @@
|
||||
const TILE_STYLE = 'https://tiles.openfreemap.org/styles/positron';
|
||||
|
||||
onMount(() => {
|
||||
// Derive initial center and zoom from preview_coords so the map starts at
|
||||
// the right location without waiting for the async detail JSON / bbox load.
|
||||
let initCenter: [number, number] = [0, 0];
|
||||
let initZoom = 1;
|
||||
if (initialCoords && initialCoords.length > 0) {
|
||||
const lats = initialCoords.map(c => c[0]);
|
||||
const lons = initialCoords.map(c => c[1]);
|
||||
initCenter = [
|
||||
(Math.min(...lons) + Math.max(...lons)) / 2,
|
||||
(Math.min(...lats) + Math.max(...lats)) / 2,
|
||||
];
|
||||
initZoom = 10; // rough default; fitBounds will correct this when bbox arrives
|
||||
}
|
||||
|
||||
map = new maplibregl.Map({
|
||||
container: mapEl,
|
||||
style: TILE_STYLE,
|
||||
center: [0, 0],
|
||||
zoom: 1,
|
||||
center: initCenter,
|
||||
zoom: initZoom,
|
||||
attributionControl: false,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user