Skip to content

Add hakunapi-tiles-generator: seed a GeoPackage tile pyramid and convert it to PMTiles - #243

Merged
jampukka merged 1 commit into
nlsfi:mainfrom
jampukka:tiles/generator
Oct 18, 2026
Merged

jampukka merged 1 commit into
nlsfi:mainfrom
jampukka:tiles/generator

Conversation

@jampukka

Copy link
Copy Markdown
Collaborator

Community module with two command-line tools. TilesGenerator renders a vector tile pyramid offline into GeoPackage tile tables, from the feature sources of a normal service configuration. PMTilesConvert converts such a table into a PMTiles v3 archive. It is a driver, not a second renderer: tiles come from the server's VectorTileGenerator, and sources load through db.classes. The PMTiles writer lives in hakunapi-tiles-source-pmtiles, beside the reader from #242. Not wired into the reference webapp.

  • Control file (concept, not a class)
    • Defines the run, separate from the service file: named zoom ranges, each with the collections drawn at those zooms and an optional CQL2 filter per collection. An optional sources property groups collections into output tables; without it each collection is its own table.
  • TilesGenerator
    • Entry point. Validates the whole control file before rendering starts, creates the tables, runs the pyramid.
  • GeneratorControl / ZoomRange / TileSources
    • Parse and validate the control file: no overlapping or uncovered zooms, each collection in exactly one source.
  • PyramidGenerator
    • Renders square blocks of tiles (-Dhakunapi.tiles.block, default 4) on a worker pool, through generateBlock when supported: the first production caller of the block API. Results are written in completion order. An empty tile writes no row.
  • PyramidTables / TilePyramidWriter
    • One shared connection and transaction; batched inserts, never committing by themselves.
  • GPKG / GPKGTilesTable / GPKGTileMatrix / MvtTilesExtension (hakunapi-gpkg)
    • Tile metadata writing, kept apart from init. The table entry carries the tiling scheme's extent, not the tiles'. Every table gets a hakunapi_mvt row in gpkg_extensions.
  • PMTilesConvert / PyramidBounds
    • Sorts tile addresses by PMTiles tile id (Hilbert index). PyramidBounds derives the header extent from the finest zoom's tiles in WGS84; no region is assumed.
  • PMTilesWriter / DirectoryWriter / HeaderWriter
    • Writes tile bodies and directories to a temporary file, then moves it into place.

Behaviour:

  • An existing GeoPackage is never overwritten; a run refuses if a target table exists, otherwise adds its tables
  • A failed render keeps the tiles already written, logs the tables as incomplete, and exits non-zero; remove them before rerunning
  • The file is written without journal or fsync, so a crashed run may leave an unusable file
  • A source id equal to a zoom range name is rejected (both read <name>.collections)
  • A range filter calling a CQL2 function fails at startup; the generator registers none
  • PMTilesConvert extent and centre default to the finest zoom's tiles; --bbox and --center override. A non-4326 pyramid needs a projection factory on the classpath, else it asks for --bbox
  • PMTilesConvert refuses a pyramid whose matrices are not 2^z by 2^z
  • PMTiles: identical tile bodies stored once; root directory over 16 kB split into leaves

@jampukka
jampukka merged commit 2712dc2 into nlsfi:main Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant