|
7 | 7 | hoverStateFilter,
|
8 | 8 | type LayerClickInfo,
|
9 | 9 | } from "svelte-maplibre";
|
10 |
| - import { Link, layerId } from "./common"; |
11 |
| - import { isLine } from "svelte-utils/map"; |
| 10 | + import { Link, Popup, layerId } from "./common"; |
| 11 | + import { isLine, isPolygon } from "svelte-utils/map"; |
12 | 12 | import { SplitComponent } from "svelte-utils/top_bar_layout";
|
13 | 13 | import { app, mode, autosave } from "./stores";
|
14 | 14 | import { downloadGeneratedFile } from "svelte-utils";
|
15 | 15 |
|
16 | 16 | let gj = JSON.parse($app!.renderAutoBoundaries());
|
| 17 | + let minArea = 0; |
17 | 18 |
|
18 | 19 | function add(e: CustomEvent<LayerClickInfo>) {
|
19 | 20 | let name = window.prompt("What do you want to name the neighbourhood?");
|
|
71 | 72 |
|
72 | 73 | <div slot="sidebar">
|
73 | 74 | <BackButton on:click={() => ($mode = { mode: "network" })} />
|
| 75 | + |
74 | 76 | <p>
|
75 | 77 | Click an area to use it as a neighbourhood. These are generated by finding
|
76 |
| - roads, railways, and water thatform severances. There are many bugs; this |
77 |
| - is experimental. |
| 78 | + roads, railways, and water that form severances. There are many bugs; this |
| 79 | + is experimental. The colors are arbitrary, just to distinguish better. |
78 | 80 | </p>
|
| 81 | + |
79 | 82 | <button class="secondary" on:click={download}>Export to GeoJSON</button>
|
| 83 | + |
| 84 | + <label> |
| 85 | + Minimum area (km²) |
| 86 | + <input type="number" bind:value={minArea} min="0" max="1" step="0.01" /> |
| 87 | + </label> |
80 | 88 | </div>
|
81 | 89 |
|
82 | 90 | <div slot="map">
|
83 | 91 | <GeoJSON data={gj} generateId>
|
84 | 92 | <FillLayer
|
85 | 93 | {...layerId("auto-boundaries-areas")}
|
| 94 | + filter={["all", isPolygon, [">=", ["get", "area_km2"], minArea]]} |
86 | 95 | manageHoverState
|
87 | 96 | paint={{
|
88 |
| - "fill-color": hoverStateFilter("cyan", "red"), |
89 |
| - "fill-opacity": 0.3, |
| 97 | + "fill-color": [ |
| 98 | + "match", |
| 99 | + ["%", ["id"], 5], |
| 100 | + 0, |
| 101 | + "blue", |
| 102 | + 1, |
| 103 | + "yellow", |
| 104 | + 2, |
| 105 | + "green", |
| 106 | + 3, |
| 107 | + "purple", |
| 108 | + 4, |
| 109 | + "orange", |
| 110 | + "black", |
| 111 | + ], |
| 112 | + "fill-opacity": hoverStateFilter(0.3, 0.7), |
90 | 113 | }}
|
91 | 114 | on:click={add}
|
92 | 115 | hoverCursor="pointer"
|
93 |
| - /> |
| 116 | + > |
| 117 | + <Popup openOn="hover" let:props> |
| 118 | + Area: {props.area_km2.toFixed(5)} km² |
| 119 | + </Popup> |
| 120 | + </FillLayer> |
94 | 121 |
|
95 | 122 | <LineLayer
|
96 | 123 | {...layerId("auto-boundaries-severances")}
|
|
0 commit comments