mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 06:26:26 +00:00
73237ffedb
The tour type is a dropdown; a bike tour picks its profile, routes for it, says when a point lies off every way, and shows what it runs on: surfaces, kinds of way and, for a mountain bike, the trail grades, each pointed at on the map. A type's own map (OpenHikingMap for a hike, CyclOSM for a bike tour) is offered while a tour of that type is open, with an admin switch each. From the planned cards: a hike avoids steep climbs, steps or ferries, nothing else; a saved tour can be shared where the platform takes GPX files; and the tours rail adds a tour from one menu: plan new, import GPX, or take one over from another trip.
24 lines
818 B
TypeScript
24 lines
818 B
TypeScript
/** The router's line as it sends it: Google's polyline encoding at the given precision. */
|
|
export function encodePolyline(points: [number, number][], precision: number): string {
|
|
const factor = 10 ** precision;
|
|
let last = [0, 0];
|
|
return points
|
|
.map((point) => {
|
|
const scaled = point.map((value) => Math.round(value * factor));
|
|
const deltas = scaled.map((value, i) => value - last[i]);
|
|
last = scaled;
|
|
return deltas
|
|
.map((delta) => {
|
|
let value = delta < 0 ? ~(delta << 1) : delta << 1;
|
|
let chunk = '';
|
|
while (value >= 0x20) {
|
|
chunk += String.fromCharCode((0x20 | (value & 0x1f)) + 63);
|
|
value >>= 5;
|
|
}
|
|
return chunk + String.fromCharCode(value + 63);
|
|
})
|
|
.join('');
|
|
})
|
|
.join('');
|
|
}
|