Skip to content

Commit

Permalink
Visualize center-with-width changes, to better debug. The output itself
Browse files Browse the repository at this point in the history
is very broken.
  • Loading branch information
dabreegster committed Jun 21, 2024
1 parent 5a78f8e commit a66e176
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions web/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
GeoJSON,
MapLibre,
hoverStateFilter,
CircleLayer,
} from "svelte-maplibre";
import type {
FeatureCollection,
Expand Down Expand Up @@ -132,6 +133,31 @@
};
}
function addLinestringEndpoints(
input: FeatureCollection<LineString>,
): FeatureCollection<Point> {
let output = {
type: "FeatureCollection" as const,
features: [],
};
for (let f of input.features) {
for (let pt of [
f.geometry.coordinates[0],
f.geometry.coordinates[f.geometry.coordinates.length - 1],
]) {
output.features.push({
type: "Feature",
properties: {},
geometry: {
type: "Point",
coordinates: JSON.parse(JSON.stringify(pt)),
},
});
}
}
return output;
}
$: if (currentTestCase != "") {
// @ts-expect-error
let test = testCases[currentTestCase];
Expand Down Expand Up @@ -299,6 +325,17 @@
</Popup>
</LineLayer>
</GeoJSON>
<GeoJSON data={addLinestringEndpoints(centerWithWidth)}>
<CircleLayer
paint={{
"circle-opacity": 0,
"circle-radius": 10,
"circle-stroke-color": "purple",
"circle-stroke-width": 2,
}}
layout={{ visibility: showCenterWithWidth ? "visible" : "none" }}
/>
</GeoJSON>
</MapLibre>
</div>
</Layout>
Expand Down

0 comments on commit a66e176

Please sign in to comment.