Skip to content

Commit

Permalink
add minLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Sep 13, 2024
1 parent ba1facb commit 14bd59d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@turf/great-circle": "^7.1.0",
"maplibre-gl": "^4.6.0",
"protomaps-themes-base": "^3.1.0",
"s2js": "^1.42.0",
"s2js": "^1.42.1",
"solid-js": "^1.8.20",
"terra-draw": "^1.0.0-beta.1"
},
Expand Down
19 changes: 16 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ const getCovering = (
coverer: geojson.RegionCoverer,
features: Feature[],
): s2.CellUnion => {
return s2.CellUnion.fromUnion(
...features.map((f) => coverer.covering(f.geometry)),
);
if (features.length > 1) throw new Error("multi-feature unsupported");
return coverer.covering(features[0].geometry);
};

// We adjust the lines from great-circle to have lng > 180 and < -180 so that
Expand Down Expand Up @@ -219,6 +218,7 @@ function App() {
let draw: TerraDraw;
let regionCoverer: geojson.RegionCoverer;

const [minLevel, setMinLevel] = createSignal(0);
const [maxLevel, setMaxLevel] = createSignal(30);
const [maxCells, setMaxCells] = createSignal(200);
const [drawMode, setDrawMode] = createSignal("");
Expand Down Expand Up @@ -275,6 +275,7 @@ function App() {

createEffect(() => {
regionCoverer = new geojson.RegionCoverer({
minLevel: minLevel(),
maxLevel: maxLevel(),
maxCells: maxCells(),
});
Expand Down Expand Up @@ -499,6 +500,18 @@ function App() {
}}
/>
</div>
<div class="input">
<div class="label">
<label>min level:</label>
</div>
<input
type="text"
value={minLevel()}
onInput={(e) => {
setMinLevel(+e.target.value || 1);
}}
/>
</div>
<div class="input">
<div class="label">
<label>max level:</label>
Expand Down

0 comments on commit 14bd59d

Please sign in to comment.