Skip to content

armgit / Aleph

Public Imported from GitHub
0

Give satellite imagery, terrain data, buildings, streetview photos to your LLM

Improve polygon selection

Belluxxf7a5c7c29a70
diff --git a/src/web/app.js b/src/web/app.js
index 347fe6d..9654e8a 100644
--- a/src/web/app.js
+++ b/src/web/app.js
@@ -288,7 +288,8 @@ const OVERLAYS = [
paint: {"circle-radius": 6, "circle-color": "--accent", "circle-stroke-color": "--paper", "circle-stroke-width": 2}},
{id: "outlines-fill", source: "outlines", type: "fill", paint: {"fill-color": "--accent", "fill-opacity": hover(0.08, 0)}},
{id: "outlines", source: "outlines", type: "line", paint: {"line-color": hover("--accent", "--ink"), "line-width": hover(2, 1)}},
- {id: "area-fill", source: "area", type: "fill", paint: {"fill-color": "--accent", "fill-opacity": 0.07}},
+ {id: "area-fill", source: "area", type: "fill", filter: ["==", ["geometry-type"], "Polygon"],
+ paint: {"fill-color": "--accent", "fill-opacity": 0.07}},
{id: "area-line", source: "area", type: "line", paint: {"line-color": "--accent", "line-width": 1.5}},
{id: "corners", source: "corners", type: "symbol",
layout: {"icon-image": "corner", "icon-allow-overlap": true, "icon-ignore-placement": true}},
@@ -573,11 +574,12 @@ function setArea(area) {
renderArea();
}
-// The area, or the polygon being drawn with a line to the pointer.
+// The area, or the polygon being drawn, closed through the pointer.
function showArea() {
const {sketch, area} = state;
if (sketch?.length) {
- setData("area", collection([line(state.cursor ? [...sketch, state.cursor] : sketch)]));
+ const points = state.cursor ? [...sketch, state.cursor] : sketch;
+ setData("area", collection([points.length > 2 ? polygon(points) : line(points)]));
setData("corners", collection(sketch.map(c => point(c))));
} else {
setData("area", area ? collection([polygon(area)]) : EMPTY);
@@ -607,6 +609,10 @@ function setDrawing(on) {
state.drawing = on;
state.sketch = on && state.tool === "polygon" ? [] : null;
state.cursor = null;
+ if (on && state.area) {
+ state.area = null; // Drawing starts over.
+ estimate();
+ }
hint(on ? HINTS[state.tool] : "");
map.getCanvas().style.cursor = on ? "crosshair" : "";
showArea();
diff --git a/src/web/icons/polygon.svg b/src/web/icons/polygon.svg
new file mode 100644
index 0000000..51ad750
--- /dev/null
+++ b/src/web/icons/polygon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="miter"><path d="M4 10l7-6 9 4-2 11-10-1z"/></svg>
diff --git a/src/web/icons/rectangle.svg b/src/web/icons/rectangle.svg
new file mode 100644
index 0000000..ff242e3
--- /dev/null
+++ b/src/web/icons/rectangle.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="miter"><path d="M4 6h16v12H4z"/></svg>
diff --git a/src/web/index.html b/src/web/index.html
index 2f3991f..cfe3630 100644
--- a/src/web/index.html
+++ b/src/web/index.html
@@ -68,8 +68,8 @@
<h2 class="label">Area</h2>
<div class="field shape"><span>Shape</span>
<span class="segmented">
- <label><input type="radio" name="shape" value="rectangle"><span>Rectangle</span></label>
- <label><input type="radio" name="shape" value="polygon"><span>Polygon</span></label>
+ <label><input type="radio" name="shape" value="rectangle"><span><i data-icon="rectangle"></i>Rectangle</span></label>
+ <label><input type="radio" name="shape" value="polygon"><span><i data-icon="polygon"></i>Polygon</span></label>
</span>
</div>
<div class="area">