Public
Edited
Oct 18, 2023
6 forks
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function polyfillCenter() {
return h3.polyfill(geometry, h3Resolution, true);
}
Insert cell
function polyfillContainmentTurf() {
const base = h3.polyfill(geometry, h3Resolution, true);
return base.filter(h3Index => contains(sf, {
type: "Feature", geometry: {
type: "Polygon",
coordinates: [h3.h3ToGeoBoundary(h3Index, true)]
}
}));
}
Insert cell
function polyfillIntersectionTurf() {
const base = h3.polyfill(geometry, h3Resolution, true);
const buffered = new Set(base.flatMap(h3Index => h3.kRing(h3Index, 1)));
return Array.from(buffered).filter(h3Index => intersects(sf, {
type: "Feature", geometry: {
type: "Polygon",
coordinates: [h3.h3ToGeoBoundary(h3Index, true)]
}
}));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
result = {
switch (polyfillMode) {
case "Center":
return timed(polyfillCenter);
case "Containment - Turf":
return timed(polyfillContainmentTurf);
case "Intersection - Turf":
return timed(polyfillIntersectionTurf);
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more