OpenHistoricalMap logo OpenHistoricalMap

Rub21's Diary

Recent diary entries

📊 OHM Vector Tile - Admin Boundary Optimization Results

Posted by Rub21 on March 24, 2025 in English. Last updated on March 27, 2025.

Vector tiles API: https://vtiles.openhistoricalmap.org/

One of the most frequently added data types in OpenHistoricalMap are boundaries. These are often represented as relations and ways, these relations are imported into the PostGIS tiler database. Many of these polygons are quite complex, sometimes covering entire countries or continents and for each relation/way, a polygons are generated.

Examples:
  • Around 362 boundary relations represent British Empire on OHM over time.
  • Around 1100 boundary relations, represent San José - California on OHM over time.

Previous Workflow for Vector Tiles

In the previous version, vector tiles were generated directly from raw boundary geometries. This method resulted in slower tile response times and significantly larger tile sizes, particularly when handling complex or high-resolution polygons.

We use PostGIS’s ST_AsMVTGeom function to generate vector tiles. When working with ST_AsMVTGeom and complex, global-scale geometries—especially those with thousands of vertices—the clipping process (cutting to the !BBOX!) can introduce significant computational overhead. This becomes especially problematic at lower zoom levels, where a single geometry may span multiple tiles, triggering expensive intersection and transformation operations.

Over time, many users began noticing that tiles were loading too slowly, particularly in regions with dense boundary data. This performance bottleneck in the boundaries layer also negatively impacted the loading speed of other map layers, resulting in an overall degraded map experience.


Improving Performance with Complex Boundaries

📎 From: GitHub Issue #800

To address the previous version of the tiler, we conducted a detailed analysis of the boundary data and implemented a merging strategy.

See full entry