Biểu trưng OpenStreetMap OpenStreetMap

Fixing places as areas in shortbread tiles

Do pnorman đăng vào 19 tháng 04 năm 2025 bằng English.

This blog post explains how I handle a typical bug report for the new OSMF Shortbread tiles. Here, I focus on the “island” seems to be missing from “place_labels” report from SomeoneElse

After verifying that the report is correct, I set up my editor environment. It’s useful to have an environment that syntax highlights Jinja SQL files, as well as other files. I use a Visual Studio Code-based editor with the Better Jinja plugin.

The issue is in the place_labels layer. After checking Shortbread, I see that place=island should show at zoom 10 or higher, so there is a bug. Tilekiln creates tiles by reading definitions from shortbread.yaml, so I check there for the place_labels definition.

place_labels:
    description: Holds label points for populated places.
    fields:
        kind: Value of OSM place tag
        name: *name
        name_en: *name_en
        name_de: *name_de
        population: Value of OSM population tag
    sql:
    - minzoom: 4
        maxzoom: 14
        file: shortbread_original/place_labels.04-14.sql.jinja2

This file shows that for zooms 4 to 14, the SQL for the layer is in shortbread_original/place_labels.04-14.sql.jinja2. Since this file is in shortbread_original, osm2pgsql-themepark created it, and it remains unchanged.

SELECT
        ST_AsMVTGeom(geom, {{unbuffered_bbox}}, {{extent}}, {{buffer}}) AS way,
        name,
        name_de,
        name_en,
        kind,
        population
    FROM place_labels
    WHERE geom && {{bbox}}
        AND {{zoom}} >= minzoom
    ORDER BY population desc

There aren’t any obvious bugs in the SQL. There’s no filtering out of islands, so either the data isn’t making it into the place_labels table or it has the wrong zoom. The data is loaded by osm2pgsql, and shortbread.lua tells osm2pgsql how to do that.

themepark:add_topic('shortbread/places')

With this line shortbread.lua loads the shortbread/places topic. This topic is in the themes/shortbread/topics/places.lua file, and in this case the file comes from osm2pgsql-themepark. When reading the file, I see that place=island is being handled, so I go to the database to find an example.

I keep Luxembourg loaded in my database, and Overpass Turbo lets me find way 1010337745 as an example. By running a query, I can find if the object is in the table. Normally I’d do this with a query like SELECT * FROM place_labels WHERE area_id = 1010337745, but as I type it out, I find there’s no area_id column, but there is node_id.

Looking back at the lua, I see the table is defined as a ‘node’ table, so it doesn’t have data from ways loaded. Most place=island are areas, so this is the problem. I need to define the table similar to the address table, where an object could be a node, way, or relation.

The pull request has all the details on how I solved this. I changed the table to accept any object type and functions to process both nodes and areas. In both cases, the code adds a label point to the table. Because this changes the tables, I’m not merging it right away as I want to make other changes before merging and reloading the database on the OSMF servers.

Biểu tượng thư điện tử Biểu tượng Bluesky Biểu tượng Facebook Biểu tượng LinkedIn Biểu tượng Mastodon Biểu tượng Telegram Biểu tượng X

Thảo luận

Bình luận của SomeoneElse vào 19 tháng 4 năm 2025 lúc 22:45

and reloading the database on the OSMF servers.

When I make a request to an OSMF vector tile it’s to something with a URL like https://vector.openstreetmap.org/shortbread_v1/9/252/166.mvt .

How is the reload process done - is it just a reload of the database from which those .mvt files are generated, or a regeneration of all .mvt files as well?

Bình luận của pnorman vào 22 tháng 4 năm 2025 lúc 22:51

The database will be reloaded then the tiles deleted and regenerated.

Đăng nhập để nhận xét