Skip to content

Commit 53170d2

Browse files
committed
Count the types of edits
1 parent 9071462 commit 53170d2

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

web/src/App.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
</script>
9191

9292
<div class="pico">
93-
<About class="pico" />
93+
<About />
9494
</div>
9595
<Layout>
9696
<div slot="top" class="pico" style="display: flex">

web/src/DebugMode.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { CircleLayer, GeoJSON, LineLayer } from "svelte-maplibre";
2+
import { CircleLayer, GeoJSON } from "svelte-maplibre";
33
import { notNull, PropertiesTable } from "svelte-utils";
44
import { Popup } from "svelte-utils/map";
55
import { SplitComponent } from "svelte-utils/top_bar_layout";

web/src/PickNeighbourhoodMode.svelte

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import type { Feature } from "geojson";
2+
import type { Feature, FeatureCollection } from "geojson";
33
import { FillLayer, GeoJSON, hoverStateFilter } from "svelte-maplibre";
44
import { downloadGeneratedFile, notNull } from "svelte-utils";
55
import { Popup } from "svelte-utils/map";
@@ -22,6 +22,7 @@
2222
$: boundaryNames = gj.features
2323
.filter((f: Feature) => f.properties!.kind == "boundary")
2424
.map((f: Feature) => f.properties!.name);
25+
$: edits = countEdits(gj);
2526
2627
function pickNeighbourhood(name: string) {
2728
$backend!.setCurrentNeighbourhood(name, $editPerimeterRoads);
@@ -79,6 +80,26 @@
7980
);
8081
}
8182
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+
82103
// TODO Hover on button and highlight on map
83104
</script>
84105

@@ -166,7 +187,18 @@
166187
</ul>
167188

168189
<hr />
190+
169191
<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+
170202
<button on:click={exportGJ}>Export project to GeoJSON</button>
171203
<button class="secondary" on:click={debugRouteSnapper}>
172204
Debug route-snapper

0 commit comments

Comments
 (0)