|
| 1 | +<script lang="ts"> |
| 2 | + import { |
| 3 | + CircleLayer, |
| 4 | + GeoJSON, |
| 5 | + LineLayer, |
| 6 | + type LayerClickInfo, |
| 7 | + } from "svelte-maplibre"; |
| 8 | + import { notNull } from "svelte-utils"; |
| 9 | + import { emptyGeojson } from "svelte-utils/map"; |
| 10 | + import { SplitComponent } from "svelte-utils/top_bar_layout"; |
| 11 | + import BackButton from "./BackButton.svelte"; |
| 12 | + import { layerId, Link } from "./common"; |
| 13 | + import { backend, mode } from "./stores"; |
| 14 | +
|
| 15 | + let movements = emptyGeojson(); |
| 16 | +
|
| 17 | + function pickIntersection(e: CustomEvent<LayerClickInfo>) { |
| 18 | + movements = $backend!.getMovements(e.detail.features[0].id as number); |
| 19 | + } |
| 20 | +</script> |
| 21 | + |
| 22 | +<SplitComponent> |
| 23 | + <div slot="top"> |
| 24 | + <nav aria-label="breadcrumb"> |
| 25 | + <ul> |
| 26 | + <li> |
| 27 | + <Link on:click={() => ($mode = { mode: "title", firstLoad: false })}> |
| 28 | + Choose project |
| 29 | + </Link> |
| 30 | + </li> |
| 31 | + <li>Debug intersections</li> |
| 32 | + </ul> |
| 33 | + </nav> |
| 34 | + </div> |
| 35 | + |
| 36 | + <div slot="sidebar"> |
| 37 | + <BackButton on:click={() => ($mode = { mode: "network" })} /> |
| 38 | + |
| 39 | + {#if movements.features.length > 0} |
| 40 | + <button class="secondary" on:click={() => (movements = emptyGeojson())}> |
| 41 | + Pick another intersection |
| 42 | + </button> |
| 43 | + <p>{movements.features.length} movements</p> |
| 44 | + {/if} |
| 45 | + </div> |
| 46 | + |
| 47 | + <div slot="map"> |
| 48 | + <GeoJSON data={notNull($backend).getAllIntersections()} generateId> |
| 49 | + <CircleLayer |
| 50 | + {...layerId("debug-intersections")} |
| 51 | + paint={{ |
| 52 | + "circle-radius": 15, |
| 53 | + "circle-color": "black", |
| 54 | + }} |
| 55 | + manageHoverState |
| 56 | + hoverCursor="pointer" |
| 57 | + on:click={pickIntersection} |
| 58 | + /> |
| 59 | + </GeoJSON> |
| 60 | + |
| 61 | + <GeoJSON data={movements} generateId> |
| 62 | + <LineLayer |
| 63 | + {...layerId("debug-movements")} |
| 64 | + paint={{ |
| 65 | + "line-width": 2, |
| 66 | + "line-color": "red", |
| 67 | + }} |
| 68 | + /> |
| 69 | + </GeoJSON> |
| 70 | + </div> |
| 71 | +</SplitComponent> |
0 commit comments