-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open a score mode desire line in route mode for details
- Loading branch information
1 parent
202847d
commit 3cf58d0
Showing
5 changed files
with
76 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
import { MapModel } from "backend"; | ||
import type { FeatureCollection } from "geojson"; | ||
import type { Map } from "maplibre-gl"; | ||
import { writable, type Writable } from "svelte/store"; | ||
import { get, writable, type Writable } from "svelte/store"; | ||
|
||
export let maptilerApiKey = "MZEJTanw3WpxRvt7qDfo"; | ||
|
||
export type Mode = "title" | "score" | "route" | "debug"; | ||
export type Mode = | ||
| { kind: "title" } | ||
| { kind: "score" } | ||
| { kind: "route"; route_a: [number, number]; route_b: [number, number] } | ||
| { kind: "debug" }; | ||
export interface RouteGJ extends FeatureCollection { | ||
direct_length: number; | ||
route_length: number; | ||
} | ||
|
||
export let mode: Writable<Mode> = writable("title"); | ||
export let mode: Writable<Mode> = writable({ kind: "title" }); | ||
export let model: Writable<MapModel | null> = writable(null); | ||
export let map: Writable<Map | null> = writable(null); | ||
export let showAbout: Writable<boolean> = writable(true); | ||
export let importStreetsWithoutSidewalkTagging: Writable<boolean> = | ||
writable(true); | ||
|
||
export function routeMode(): Mode { | ||
let bbox: number[] = Array.from(get(model)!.getBounds()); | ||
return { | ||
kind: "route", | ||
route_a: [lerp(0.4, bbox[0], bbox[2]), lerp(0.4, bbox[1], bbox[3])], | ||
route_b: [lerp(0.6, bbox[0], bbox[2]), lerp(0.6, bbox[1], bbox[3])], | ||
}; | ||
} | ||
|
||
function lerp(pct: number, a: number, b: number): number { | ||
return a + pct * (b - a); | ||
} |