bitbaum Start a project
Package · MIT

geo-kit

Versioned, on-demand geography resources and sourced boundary assertions for web applications, and a Canvas 2D renderer for them (globe or map).

LicenceMIT
Registry releasev0.5.0
Install
Sourcebitbaum/geo-kit
Declared consumers3 repositories

API and examples

Documentation from source commit e15126d202a1 · 2026-11-10. Source documentation can include work beyond the registry release.

Read the package documentation

Country-neutral contracts for sharing versioned geography data across applications, and one renderer for it (@bitbaum/geo-kit/map). The package owns no country packs, political claims, source choices, personal data, HTTP server, or UI framework.

Install

pnpm add @bitbaum/geo-kit

Install releases from npm, not a commit: a semver range is what lets a fix reach every product. @bitbaum/geo-kit@0.1.1 is on npm; later releases are published by this repository's publish.yml.

Ownership

  • Solon is the authoritative owner of public places, source records,

historical assertions, decisions, and published boundary resources.

  • OrangeCat remains the owner of private residence and account data.
  • Substrata and other clients consume public, versioned data and choose the

layers they need. They do not copy Solon's geography database.

  • Application policy supplies accepted licences and controls whether a

proposal is approved. This package does not make that decision.

Data loading

Publish a small manifest beside content-addressed GeoJSON or TopoJSON resources. Each resource identifies its source, geography, open-ended layer and level keys, validity period, optional map viewpoint, URL, SHA-256 digest, size and feature count. Resources can reference multiple sources, with each source's licence and attribution checked independently. Viewpoints have names, descriptions and source references, so a client can explain which representation it displays. A client asks for one or more geography/resource IDs, a date, and (when needed) a viewpoint. The default view includes only resources with no explicit viewpoint. selectGeographyResources rejects broad accidental loads by default and enforces byte/resource limits before any request is made.

loadGeographyResources fetches selected same-origin URLs only, without cookies and without following redirects. It checks the decoded file size, SHA-256, GeoJSON/TopoJSON structure and feature count before returning parsed data. It accepts an injected cache, fetch implementation and abort signal so each app can use its own HTTP cache, IndexedDB policy and retry interface. Requests are bounded-concurrency and results use deterministic geography/kind/level/id order.

loadGeographyManifest uses the same transport protections for the manifest, including a decoded byte limit enforced while streaming (64 KiB by default). An abort cancels a stalled body and also stops loads served from a cache.

Resource selection can include a WGS84 bbox in west/south/east/north order. Only intersecting resources with known bounds are selected. Resources without bounds remain eligible, so missing metadata cannot silently hide coverage. West greater than east represents an antimeridian crossing. Geographic, time, viewpoint and download-budget selectors continue to apply together.

import { loadGeographyManifest, loadGeographyResources } from '@bitbaum/geo-kit';

const controller = new AbortController();
const options = {
  baseUrl: window.location.origin,
  licensePolicy: [{ spdx: 'CC0-1.0', requiresAttribution: false }],
  signal: controller.signal, // AbortController owned by the application
};
const manifest = await loadGeographyManifest('/geography/manifest.json', options);
const layers = await loadGeographyResources(manifest, {
  geographyIds: ['selected-geography'],
  asOf: '2026-09-30', // the date displayed by the application
  levelKeys: ['subdivision'],
  bbox: [7, 46, 9, 48],
  maxBytes: 512 * 1024,
}, options);

Layer keys and geographic IDs in this example come from the application's data. Country packs, detailed subdivision datasets and a border drawing UI are separate deliverables owned by the applications; this package does not invent or publish them.

The library never reads the system clock. Pass the date displayed by the app to support historical maps deterministically. An explicit viewpoint is opt-in; the library does not treat any boundary representation as the default truth.

Drawing it: @bitbaum/geo-kit/map

One map for every product: an orthographic globe on Canvas 2D (d3-geo). Zoomed far in, the globe is a flat map of the place in front of the reader, so the world, a country and a commune are one projection and one renderer. Canvas 2D rather than WebGL: a few thousand path segments a frame fit a phone's frame budget, and it runs wherever the page runs.

pnpm add @bitbaum/geo-kit d3-geo topojson-client

d3-geo (and topojson-client, for TopoJSON) are optional peer dependencies: a product that only loads data does not install them.

import { cameraForBounds, createMap, shapesFromTopology } from "@bitbaum/geo-kit/map";

const shapes = shapesFromTopology(topology, { object: "communes", idOf: (f) => String(f.id) });
const limits = { minZoom: 1, maxZoom: 2000, maxTilt: 80 };
const map = createMap(canvas, {
  shapes,
  palette: { sphere: "#fff", land: "#eee", border: "#999", hover: "#555", selected: "#000" },
  fills: new Map([["261", "#08519c"]]),
  limits,
  onSelect: (id) => console.log(id),
});
map.resize(390, 600);
map.flyTo(cameraForBounds([5.96, 45.82, 10.49, 47.81], limits));
  • Names. Pass labels ({ id, text, at, rank, kind, minZoom, maxZoom, dot })

and a style per kind; the map places them each frame without overlap, most important first, and only those in their zoom band and facing the reader. onSelectLabel makes them tappable. A density budget, per-style padding, globe-aware culling, stable placement and fades keep it calm; box and leader make callouts.

  • Layers. Give a feature that lies over another (a province over its country) a higher

layer; layers are painted in order and never merged into one path.

  • Zoom where you point. Wheel and pinch zoom about the pointer; double click

or double tap zooms in on the spot, Shift + double click zooms out.

  • Framework-free. createMap takes a <canvas> and returns methods

(resize, setFills, setSelected, flyTo, zoomBy, destroy, …); a React or other page wraps it in a few lines and keeps no map state of its own.

  • Input. One finger or the mouse turns it, two pinch, the wheel zooms, a

tap selects, a flick coasts. The keyboard treats the canvas as one control: arrows turn, + and − zoom, Home resets, Enter selects what faces the reader.

  • Cost. It draws only when something changes; in motion it paints the

coarse shapes (every third vertex of each shared arc, so neighbours still meet), and full detail the frame after. Features on the far side, or off the canvas when zoomed, are not drawn.

  • Reduced motion. Under prefers-reduced-motion a flight is a cut, a flick

does not coast and the idle turn never starts.

  • Layers. The palette's sphere, graticule, glow and limb shade are each

optional, so a lit globe of the world and a plain map where the data is the picture are the same painter. over draws the caller's own layer (sites, routes, figures) on top each frame, with the frame's projection, and pickFirst lets that layer take a tap or a hover before the features.

  • Picking is top-down. A tap picks the feature on the highest layer that holds the point

(a commune over its country), the smallest area on one layer, so coarse Natural Earth countries never take a tap inside a fine place drawn over them. pickAllAt returns the whole stack, topmost first, for contested land and for a country > state > county > town chain. See docs/design/picking.md.

  • Pure parts. The camera, motion, culling, picking and the fast

projection are exported and tested without a browser.

Which place the map is about: createFocus

A map of places (a country, its provinces, their districts) needs one rule, kept in one place: choosing a place selects it, frames its own outline, draws its children as the tappable places with its own outline whole, and shows the places above it faintly. It never frames from a child's bounds, and nothing jumps to a child that was not chosen.

import { createFocus } from "@bitbaum/geo-kit/map";

const focus = createFocus(
  {
    cameraOf: (id) => outlineCameraOf(id), // cameraFor(its geometry), or null when none is drawn
    childrenOf: (id) => idsInside(id),
    parentOf: (id) => idAbove(id),
    home: { center: [8, 40], k: 1 },
  },
  (view) => {
    if (view.camera) map.flyTo(view.camera);
    map.setSelected(view.selected);
    // draw view.outline and view.children; view.context faintly; the card says "Open <view.selected>"
  },
);
focus.choose("some-place"); // a tap, a search result, a link
focus.up();

hatch(stripe) makes a fill for land more than one authority claims.

Assertions and proposed boundaries

AreaAssertion follows Solon's sourced claims, administers, and proposes records. summarizeAreaAssertions filters those records by an explicit date and reports distinct claimants, administrators and proposers. Its disputed flag is a mechanical summary of competing claims or a mismatch between claimant and administrator; it is not a legal conclusion.

validateBoundaryDraft checks a proposal's polygon, WGS84 coordinates, closed rings, input limits, source/license metadata and validity interval. Publication stays blocked until the consuming app provides both a full geometry-topology validator and an approval check for the draft's proposal. The draft contains a shape and its provenance only; claims about who owns or administers it are separate sourced assertions.

Verify

pnpm install --frozen-lockfile
pnpm run verify

Runtime code has no dependencies and targets modern browsers plus Node.js 20 or later. The package ships JavaScript and declarations built from the TypeScript source, so consumers do not need a TypeScript-aware runtime loader.

Changelog and releases

Read the repository changelog

0.8.0

  • Borders are stroked layer by layer. Each layer's fills are painted, then its own border

lines, so a layer over another covers the lines under it. Before, every border was stroked in one pass over every fill, and a coarse country's outline (Natural Earth 1:50m, kilometres off) ran across the fine places drawn over it: Russia's across Narva, the German/Polish border across Görlitz. A map with one layer paints exactly as before. Shapes gains lineLayers; shapesOf takes it as an optional third argument, shapesFromFeatures fills it from each feature's layer.

  • Picture tests (test/visual.test.ts, baselines in test/visual, rendered in process with Skia):

the five border fixtures painted as Solon paints them, the picked place highlighted, and a check that no coarse border pixel inside a fine place is stroked over it.

0.7.0

  • Fix: a tap picks the place drawn on top. pickAt walked the features in array order and

ignored layer, so a coarse country listed first took every tap inside a fine place drawn over it (Solon: a tap inside Narva selected Russia). The index is now topmost first: highest layer, then smallest area, then listed last. See docs/design/picking.md.

  • pickAllAt(index, projection, x, y): every feature under the pixel, topmost first (the

commune, its province, its country; each claimant of contested land), empty over the sea.

  • Pickable now carries layer and area.

0.6.0

  • createFocus / choose / up (/map): which place a map is about, as one pure state

machine (no canvas, no framework, no country). Choosing a place selects it, frames its own outline (never a child's, never the bounds of whatever happens to be drawn inside it: a country of which one province has boundaries is still framed as the whole country; only a place with no outline of its own is framed by what is inside it), draws its children as the tappable places with its own outline whole, and gives the places above it as faint context. Nothing jumps to a child that was not chosen; up() is the same choice made on the parent. The tree is three functions the app supplies (cameraOf, childrenOf, parentOf).

  • hatch(stripe, options): a diagonal hatch fill for land more than one authority claims, so

colour is never the only carrier.

0.5.0

  • Labels that read like an atlas, not a wall of names:

- A density budget (labelDensity, default one name per 9,000 px²) caps how many names share the screen, most important first. - Breathing room per style (padding, default 4 px). - Globe-aware: nothing within 18° of the limb, where text smears, and nothing outside the globe's disc or within 6 px of the canvas edge. - Steady: a name shown last frame keeps its place against an equal newcomer, and while the reader drags, flies or coasts no newcomer jumps in. Names fade in and out (labelFade, default 260 ms; instant under reduced motion). - Keep clear: labelKeepClear returns boxes (buttons, a legend) names stay out of. - Callouts: a style with box draws the name on a filled box instead of a halo, and with leader sets it off from its dot, joined by a line, for a figure beside a country.

  • Layers: a MapFeature can carry layer. Features on a higher layer (a province over its

country) are painted after the ones below and never share a path with them, where overlapping shapes cancelled each other out under the even-odd rule and drew land as sea.

0.4.0

  • /map: names on the map. labels (and setLabels) take every country,

region and town once, each with a rank and a zoom band; each frame places those in front of the reader, most important first, so that none covers another, and zooming in reveals smaller places as room appears. A town is a dot with its name beside it, tried right, left, above and below. labelStyles styles each kind (font, colour, halo, dot, uppercase, tracking); onSelectLabel makes names and dots tappable. The layout is pure (layoutLabels, with the text measure injected) and tested without a canvas.

  • Zoom goes where the reader points: the wheel zooms about the cursor, a

pinch about the fingers, and a double click or double tap zooms in on the point (Shift + double click zooms out). zoomAt does the same from code.

  • hoverFill and selectedFill in the palette wash the whole place under the

pointer or selected, not only its edge.

0.3.0

  • /map: what a globe with its own layer needs, from moving Substrata's

globe onto it. pickFirst lets the caller's layer (a site, a marker) take a tap or a hover before the features; onFacing names the feature facing the reader after a keyboard turn; jumpTo goes to a view with no flight; each frame's sinceTouch tells an animated layer how long the map has been left alone. The hover label clears when a gesture starts.

0.2.0

  • Add @bitbaum/geo-kit/map: one Canvas 2D renderer for the geography this

package delivers, an orthographic globe that zoomed in is a flat map, so the world and a commune are one projection. Framework-free createMap (turn, pinch, wheel, keyboard, tap to select, flights, coasting, reduced motion), shapes from TopoJSON or GeoJSON keyed by any id, fills by id, and the pure camera, motion, culling, picking and fast-projection helpers. Extracted from Substrata's globe, so Solon's map and Substrata's globe are one renderer.

  • d3-geo and topojson-client are optional peer dependencies, needed only

by /map.

0.1.1

  • Add bounded, same-origin manifest downloads with source and licence validation.
  • Share streamed transport between manifests and geometry; cancel stalled bodies

and stop cached resource loads when the consumer aborts.

  • Filter resources by viewport bounds before applying the download budget,

including antimeridian crossings. Bounds remain optional for existing data.

  • Retain the explicit geography, date and viewpoint contract from 0.1.0.

0.1.0

  • Introduce sourced geography manifests, bounded resource selection and loading,

SHA-256 verification, WGS84 geometry validation, dated area assertions and proposal-gated boundary draft validation.

  1. v0.2.0
    Release notes

    What's Changed

    * docs(agents): the org rules block, generated from bitbaum/fleet by @catomean in https://github.com/bitbaum/geo-kit/pull/13 * feat(map): one renderer for the geography geo-kit delivers (0.2.0) by @catomean in https://github.com/bitbaum/geo-kit/pull/14

    Full Changelog: https://github.com/bitbaum/geo-kit/compare/v0.1.2...v0.2.0

  2. v0.1.2
    Release notes

    What's Changed

    * ci: unified tokenless trusted-publishing workflow by @catomean in https://github.com/bitbaum/geo-kit/pull/5 * chore: add the fleet package template files this repo is missing (AGENTS.md, CLAUDE.md) by @catomean in https://github.com/bitbaum/geo-kit/pull/6 * chore: add the fleet package template files this repo is missing (release-notify.yml) by @catomean in https://github.com/bitbaum/geo-kit/pull/7 * docs(readme): install from npm, the way the registry says by @catomean in https://github.com/bitbaum/geo-kit/pull/8 * ci(publish): the fleet's one publish.yml, with a no-publish check of the npm link by @catomean in https://github.com/bitbaum/geo-kit/pull/9 * docs(agents): the org rules block, generated from bitbaum/fleet by @catomean in https://github.com/bitbaum/geo-kit/pull/10 * chore(deps): dependabot leaves TypeScript 7 alone until typescript-eslint supports it by @catomean in https://github.com/bitbaum/geo-kit/pull/11

    Full Changelog: https://github.com/bitbaum/geo-kit/compare/v0.1.1...v0.1.2

  3. v0.1.1
    Release notes

    What's Changed

    * feat: bound manifest downloads and select geography by viewport by @catomean in https://github.com/bitbaum/geo-kit/pull/1 * Document the usable immutable install pin by @catomean in https://github.com/bitbaum/geo-kit/pull/2 * chore: add the fleet package template files this repo is missing (dependabot.yml, auto-merge.yml, git-release.yml, release.yml) by @catomean in https://github.com/bitbaum/geo-kit/pull/3

    New Contributors

    * @catomean made their first contribution in https://github.com/bitbaum/geo-kit/pull/1

    Full Changelog: https://github.com/bitbaum/geo-kit/commits/v0.1.1

Recent source changes

Repository activity can include unreleased work; it is not a list of deployed changes.

  1. docs(picking): measured tap cost, and a bench script (#23)
  2. feat(map): borders stroked layer by layer; picture tests (0.8.0) (#22)
  3. fix(map): a tap picks the place drawn on top, and pickAllAt returns the stack (0.7.0) (#21)
  4. feat(map): createFocus, the rule for which place a map is about, and hatch for contested land (0.6.0) (#20)
  5. feat(map): calm labels (density, padding, globe-aware, steady, fades, callouts) and paint layers (0.5.0) (#19)
  6. feat(map): labels with collision, zoom where you point, place washes (0.4.0) (#18)
  7. docs(agents): the org rules block, generated from bitbaum/fleet (#16)
  8. feat(map): pickFirst, onFacing, jumpTo and sinceTouch, for a globe with its own layer (0.3.0) (#15)
All releases · All tags

Where it is declared

Linked products declare this package in their manifests. A declaration alone does not verify every feature, version or deployed integration.

Sources and verification

Install commands and declared consumers come from Fleet’s generated registry. Documentation and release notes come from the package repository. The catalogue does not certify production journey coverage.

Documentation from source commit e15126d202a1 · 2026-11-10. Source documentation can include work beyond the registry release.

Package verification runs