Public
Edited
Apr 20
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
A5 = import("https://esm.sh/a5-js")
Insert cell
children = A5.cellToChildren(0n, n)
Insert cell
mean = (4 * Math.PI) / children.length
Insert cell
penta = {
const mem = new Map();
return (cell) => {
if (!mem.has(cell)) {
const p = A5.cellToBoundary(cell);
const poly = rewind({
type: "Polygon",
coordinates: [[...p, p[0]].reverse()]
});
poly.area = d3.geoArea(poly);
mem.set(cell, poly);
}
return mem.get(cell);
};
}
Insert cell
import { rewind } from "@fil/rewind"
Insert cell
Insert cell
Plot.plot({
projection: { type: "equal-earth", rotate: [0, 0, 0.000001] },
marks: [
Plot.sphere({
stroke: "black",
fill: "white",
render: function (index, scales, values, dimensions, context, next) {
const g = next(index, scales, values, dimensions, context);
d3.select(g)
.select("path")
.on("click", (event, i) => {
console.log(cell);
mutable start = A5.bigIntToHex(A5.cellToParent(cell));
});
return g;
}
}),
Plot.graticule(),
Plot.geo(A5.cellToChildren(cell, A5.getResolution(cell) + 1), {
geometry: penta,
fill: "orange",
fillOpacity: 0.2,
stroke: "orange",
render: function (index, scales, values, dimensions, context, next) {
const g = next(index, scales, values, dimensions, context);
d3.select(g)
.selectAll("path")
.on("click", (event, i) => {
mutable start = A5.bigIntToHex(this.data[i]);
});
return g;
}
}),
Plot.geo(cell ? [cell] : [], { stroke: "red", geometry: penta })
]
})
Insert cell
cell = A5.hexToBigInt(start)
Insert cell
mutable start = "0"
Insert cell
mutable debug = null
Insert cell
areas = A5.cellToChildren(0n, 6).map((d) => d3.geoArea(penta(d)) * 4 ** 6)
Insert cell
A5.cellToChildren(cell).map((d) => A5.bigIntToHex(d))
Insert cell
A5.cellToChildren(cell)
Insert cell
A5.cellToLonLat(A5.hexToBigInt("635fb3a800000000"))
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