|
1 | 1 | <script lang="ts">
|
2 |
| - import type { Feature } from "geojson"; |
| 2 | + import type { Feature, FeatureCollection } from "geojson"; |
3 | 3 | import { FillLayer, GeoJSON, hoverStateFilter } from "svelte-maplibre";
|
4 | 4 | import { downloadGeneratedFile, notNull } from "svelte-utils";
|
5 | 5 | import { Popup } from "svelte-utils/map";
|
|
22 | 22 | $: boundaryNames = gj.features
|
23 | 23 | .filter((f: Feature) => f.properties!.kind == "boundary")
|
24 | 24 | .map((f: Feature) => f.properties!.name);
|
| 25 | + $: edits = countEdits(gj); |
25 | 26 |
|
26 | 27 | function pickNeighbourhood(name: string) {
|
27 | 28 | $backend!.setCurrentNeighbourhood(name, $editPerimeterRoads);
|
|
79 | 80 | );
|
80 | 81 | }
|
81 | 82 |
|
| 83 | + function countEdits(gj: FeatureCollection): { |
| 84 | + modalFilters: number; |
| 85 | + deletedModalFilters: number; |
| 86 | + directions: number; |
| 87 | + } { |
| 88 | + let modalFilters = 0; |
| 89 | + let deletedModalFilters = 0; |
| 90 | + let directions = 0; |
| 91 | + for (let f of gj.features) { |
| 92 | + if (f.properties!.kind == "modal_filter") { |
| 93 | + modalFilters++; |
| 94 | + } else if (f.properties!.kind == "deleted_existing_modal_filter") { |
| 95 | + deletedModalFilters++; |
| 96 | + } else if (f.properties!.kind == "direction") { |
| 97 | + directions++; |
| 98 | + } |
| 99 | + } |
| 100 | + return { modalFilters, deletedModalFilters, directions }; |
| 101 | + } |
| 102 | +
|
82 | 103 | // TODO Hover on button and highlight on map
|
83 | 104 | </script>
|
84 | 105 |
|
|
166 | 187 | </ul>
|
167 | 188 |
|
168 | 189 | <hr />
|
| 190 | + |
169 | 191 | <p>Current project: {$projectName}</p>
|
| 192 | + |
| 193 | + <p> |
| 194 | + {edits.modalFilters} new modal filter(s) added |
| 195 | + </p> |
| 196 | + <p> |
| 197 | + {edits.deletedModalFilters} |
| 198 | + existing modal filter(s) removed |
| 199 | + </p> |
| 200 | + <p>{edits.directions} road segment direction(s) changed</p> |
| 201 | + |
170 | 202 | <button on:click={exportGJ}>Export project to GeoJSON</button>
|
171 | 203 | <button class="secondary" on:click={debugRouteSnapper}>
|
172 | 204 | Debug route-snapper
|
|
0 commit comments