mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-19 09:22:12 +00:00
sparser data transfers
This commit is contained in:
1 parent
48325e6016
commit
4583874e7e
23 files changed
+509
-229
No files matched your search
@@ -4,7 +4,8 @@
|
||||
* and the documentation. They are the ones that the engine computes for `example.gpx`, kept as
|
||||
* they are (see `example-data.ts`) so that the example does not need the engine.
|
||||
*/
|
||||
import type { GlobalStatistics, SelectionStatistics } from '$lib/engine';
|
||||
import type { GlobalStatistics, SelectionPoint, SelectionStatistics } from '$lib/engine';
|
||||
import { intervalAt } from '$lib/engine/trackpoint-categories';
|
||||
import { exampleData as data } from '$lib/data/example/example-data';
|
||||
|
||||
const length = data.lng.length;
|
||||
@@ -46,6 +47,21 @@ async function slice(start: number, end: number): Promise<GlobalStatistics | und
|
||||
};
|
||||
}
|
||||
|
||||
const slopeSegmentStarts = Uint32Array.from(data.slopeSegmentStarts);
|
||||
|
||||
/** The data of the trackpoint at `index`, as the engine gives it (the example has no OSM data). */
|
||||
async function point(index: number): Promise<SelectionPoint | undefined> {
|
||||
if (!(index >= 0 && index < length)) {
|
||||
return undefined;
|
||||
}
|
||||
const segment = intervalAt(slopeSegmentStarts, index);
|
||||
return {
|
||||
time: data.timestamps[index],
|
||||
slopeSegmentSlope: data.slopeSegmentSlopes[segment],
|
||||
slopeSegmentDistance: data.slopeSegmentDistances[segment],
|
||||
};
|
||||
}
|
||||
|
||||
export const exampleStatistics: SelectionStatistics = {
|
||||
global: data.global,
|
||||
length,
|
||||
@@ -54,10 +70,12 @@ export const exampleStatistics: SelectionStatistics = {
|
||||
lng: Float64Array.from(data.lng),
|
||||
lat: Float64Array.from(data.lat),
|
||||
ele: Float64Array.from(data.ele),
|
||||
timestamps: BigInt64Array.from(data.timestamps, (time) => BigInt(time)),
|
||||
speed: Float64Array.from(data.speed),
|
||||
atemp: Float64Array.from(data.atemp),
|
||||
slopeSegmentSlope: Float64Array.from(data.slopeSegmentSlope),
|
||||
slopeSegmentDistance: Float64Array.from(data.slopeSegmentDistance),
|
||||
slopeSegments: {
|
||||
starts: slopeSegmentStarts,
|
||||
slopes: Float64Array.from(data.slopeSegmentSlopes),
|
||||
},
|
||||
slice,
|
||||
point,
|
||||
};
|
||||
Reference in new issue
Block a user