-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45e11b0
commit 7435130
Showing
8 changed files
with
149 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts"> | ||
import { CircleLayer, hoverStateFilter } from "svelte-maplibre"; | ||
import { PropertiesTable, notNull } from "svelte-utils"; | ||
import { Popup } from "svelte-utils/map"; | ||
import type { Feature, Point } from "geojson"; | ||
export let hovered: Feature<Point> | null = null; | ||
</script> | ||
|
||
<CircleLayer | ||
id="amenities" | ||
paint={{ | ||
"circle-radius": 5, | ||
"circle-opacity": 0, | ||
"circle-stroke-width": 2, | ||
"circle-stroke-color": hoverStateFilter("orange", "red"), | ||
}} | ||
manageHoverState | ||
filter={["has", "amenity_kind"]} | ||
on:click={(e) => | ||
window.open(notNull(e.detail.features[0].properties).osm_id, "_blank")} | ||
hoverCursor="pointer" | ||
eventsIfTopMost | ||
bind:hovered | ||
> | ||
<Popup openOn="hover" let:props> | ||
<PropertiesTable properties={props} /> | ||
</Popup> | ||
</CircleLayer> |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script lang="ts"> | ||
import type { Feature, Point, FeatureCollection } from "geojson"; | ||
// Can contain things besides amenities | ||
export let gj: FeatureCollection; | ||
interface Amenity { | ||
amenity_kind: string; | ||
osm_id: string; | ||
name?: string; | ||
brand?: string; | ||
cuisine?: string; | ||
} | ||
$: amenityFeatures = gj.features.filter( | ||
(f) => "amenity_kind" in f.properties!, | ||
) as Feature<Point, Amenity>[]; | ||
// Sorted by number of members | ||
function groupByKind( | ||
features: Feature<Point, Amenity>[], | ||
): [string, Feature<Point, Amenity>[]][] { | ||
let map = new Map(); | ||
for (let f of features) { | ||
if (!map.has(f.properties.amenity_kind)) { | ||
map.set(f.properties.amenity_kind, []); | ||
} | ||
map.get(f.properties.amenity_kind).push(f); | ||
} | ||
let list = [...map.entries()]; | ||
list.sort((a, b) => b[1].length - a[1].length); | ||
return list; | ||
} | ||
function describe(f: Feature<Point, Amenity>): string { | ||
let label = f.properties.name || `a ${f.properties.amenity_kind}`; | ||
if (f.properties.brand) { | ||
label += ` (${f.properties.brand})`; | ||
} | ||
if (f.properties.cuisine) { | ||
label += ` (${f.properties.cuisine})`; | ||
} | ||
return label; | ||
} | ||
</script> | ||
|
||
{#each groupByKind(amenityFeatures) as [kind, list]} | ||
<details> | ||
<summary>{kind} ({list.length})</summary> | ||
<ol> | ||
{#each list as f} | ||
<li><a href={f.properties.osm_id} target="_blank">{describe(f)}</a></li> | ||
{/each} | ||
</ol> | ||
</details> | ||
{/each} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script lang="ts"> | ||
import type { TravelMode } from "../stores"; | ||
export let travelMode: TravelMode; | ||
</script> | ||
|
||
<label | ||
>Mode: | ||
<select bind:value={travelMode}> | ||
<option value="car">Car</option> | ||
<option value="bicycle">Bicycle</option> | ||
<option value="foot">Foot</option> | ||
<option value="transit">Public transit</option> | ||
</select> | ||
</label> |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<script lang="ts"> | ||
import { CircleLayer, hoverStateFilter } from "svelte-maplibre"; | ||
import { notNull, Modal } from "svelte-utils"; | ||
import { Popup } from "svelte-utils/map"; | ||
let next_steps: [any][] | null = null; | ||
</script> | ||
|
||
<CircleLayer | ||
id="stops" | ||
paint={{ | ||
"circle-radius": 5, | ||
"circle-color": hoverStateFilter("cyan", "blue"), | ||
}} | ||
manageHoverState | ||
filter={["has", "next_steps"]} | ||
on:click={(e) => | ||
(next_steps = JSON.parse( | ||
notNull(e.detail.features[0].properties).next_steps, | ||
))} | ||
hoverCursor="pointer" | ||
eventsIfTopMost | ||
> | ||
<Popup openOn="hover" let:props | ||
>{props.name} has {JSON.parse(props.next_steps).length} next steps (arrivals)</Popup | ||
> | ||
</CircleLayer> | ||
|
||
{#if next_steps} | ||
<Modal on:close={() => (next_steps = null)}> | ||
{#each next_steps as x} | ||
<p>{JSON.stringify(x)}</p> | ||
{/each} | ||
</Modal> | ||
{/if} |
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 +1,5 @@ | ||
export { default as AmenityLayer } from "./AmenityLayer.svelte"; | ||
export { default as AmenityList } from "./AmenityList.svelte"; | ||
export { default as NavBar } from "./NavBar.svelte"; | ||
export { default as PickTravelMode } from "./PickTravelMode.svelte"; | ||
export { default as StopsLayer } from "./StopsLayer.svelte"; |