Skip to content

Merge Point and Centroid in a single layer - vector tiles for simplified styling #1040

Closed

Description

@Rub21

Currently in the VTiles, we have some layers representing areas from which we’ve extracted centroids to improve map styling. However, in some cases, we are duplicating layers: one containing points directly from OHM data, and another containing centroids derived from area geometries. For example:
• water_areas → we also have a layer called water_areas_centroids
• amenity_areas → we also have amenity_areas_centroids, and additionally amenity_points
• landuse_areas → we also have landuse_areas_centroids, and also landuse_points
• other_areas → we also have other_areas_centroids, and also other_points

To reduce the number of layers in the stylesheet, it might be worth considering combining both the points and the centroids into a single layer, since they represent the same type of data. We could use a distinguishing attribute like source—similar to the approach we’re taking with the buildings layer. #940 (comment)

What do you think about this approach?

cc. @1ec5 @tsinn @danrademacher

Activity

  1. added
    tiler-imposm
    tiler-server
    on Apr 30, 2025
  2. 1ec5 commented on Apr 30, 2025

    @1ec5
    Member

    Yes please. The style specification has always had a built-in operator for distinguishing between point, linear, and polygonal features, so no additional attribute should be necessary.

    We’ll need to coordinate this change with @tsinn for the official styles. I don’t know of anyone else depending on the structure of our vector tiles that specifically, but we can announce something once the change is about to land.

  3. Rub21 commented on Apr 30, 2025

    @Rub21
    MemberAuthor

    Yes please. The style specification has always had a built-in operator for distinguishing between point, linear, and polygonal features, so no additional attribute should be necessary.

    it works for this data type point/line/polygon, but I mean, in case we may need a styling attribute to distinguish between direct points and derived centroids.

  4. 1ec5 commented on May 1, 2025

    @1ec5
    Member

    If I’m not mistaken, a derived centroid point’s source_type would be way or relation, right? So the stylesheet could detect a direct point as having both a geometry-type of point and a source_type of node.

  5. Rub21 commented on May 6, 2025

    @Rub21
    MemberAuthor

    After evaluating the current landuse_areas_centroids and landuse_points layers in the map styles, we found they are used starting at zoom level 10. However, in the vector tiles, they are currently available from zoom level 3. Since we are now refactoring them into a single landuse_points_centroids layer, this new layer will start at zoom level 10 to align with the map style usage and reduce the overall vector tile size.

    Image

    Doc: https://docs.google.com/spreadsheets/d/1Z36eTkEx-SsLK2z_gKPf1aGx0WroeRAN72A4pAF6IEw/edit?usp=sharing

  6. changed the title [-]Proposal to combine Point and Centroid layers in vector tiles for simplified styling[/-] [+]Merge Point and Centroid in a single layer - vector tiles for simplified styling[/+] on May 8, 2025
  7. Rub21 commented on May 8, 2025

    @Rub21
    MemberAuthor

    I’ve added the layers that merge points and centroids, based on the document I extracted from map-styles, which outlines from which zoom level each layer is used.

    For most point layers, they are used starting from zoom level 14, except for landuse, which is used starting from zoom 10. according to the document

    Added layers:

    • amenity
      amenity_points_centroids

    • buildings
      buildings_points_centroids

    • landuse
      landuse_points_centroids
      landuse_points_centroids
      landuse_points_centroids

    • other areas
      other_points_centroids

    • transport
      transport_points_centroids

    The new layers are more complete and include additional information—for example, the area field (height for buildings), which is derived from the original polygons. This field is only present when the point comes from polygons; otherwise, it will be null.

    Also, most centroids are filtered to include only polygons that have a name. If a polygon doesn’t have a name, a centroid is not created.

    Currently deployed in staging: https://vtiles.staging.openhistoricalmap.org/

    cc . @tsinn @1ec5

  8. Rub21 commented on May 8, 2025

    @Rub21
    MemberAuthor

    @tsinn @1ec5 Regarding place_points and land_ohm_centroids, both represent boundary points. Do you think it’s appropriate to merge them into a single layer, as we did with other layers?

    Also, the layers land_ohm_lines, land_ohm_centroids, and land_ohm_maritime would benefit from more descriptive names, as they all represent boundaries.

  9. tsinn commented on May 8, 2025

    @tsinn

    Yes, thinking about this briefly, seems like a fine idea to merge into a single layer.

  10. Rub21 commented on May 12, 2025

    @Rub21
    MemberAuthor

    After reading more about the documentation on place and boundary, it seems they serve different purposes and merging them is not ideal. The place tag is typically used in a more informal or descriptive way and can be applied to points or polygons. On the other hand, boundary=administrative with admin_level is used to define official administrative divisions. Therefore, it’s better to keep them separate based on their intended use.

    Attribute place=* boundary=administrative + admin_level=*
    Purpose Descriptive / informal location tagging Official administrative boundaries
    Common usage place=city, place=suburb, place=hamlet boundary=administrative, admin_level=2, admin_level=8
    Geometry type Point (usually), but can also be a polygon Always polygon or relation
    Legal authority No (informal or geographic) Yes (government-defined divisions)
    Examples City center, rural village, neighborhood name National borders, state or district boundaries
    Use case Map label or reference point Political or administrative mapping

    On the other hand, I noticed there are place_areas that don’t have labels shown on the map. So it seems we could extract centroids from those areas and combine them with the existing place_points, similar to what we’re doing with landuse and amenity layers.
    e.g https://www.openhistoricalmap.org/relation/2513656#map=17/43.818148/146.914904&layers=O&date=1744-06-02&daterange=1-01-01,2025-12-31 , Many of these island has name but does not shows in the map.

    Image

    So my proposal is to create centroids from place_areas and combine them with the existing place_points, while keeping them in a separate layer from the boundary centroids.
    What do you think?

    cc. @tsinn @1ec5

  11. Rub21 commented on May 16, 2025

    @Rub21
    MemberAuthor

    I have completed the points_centroids layer for different categories. Here is a summary of the layers and their sources:

    Category Table Sources Type Generated View(s)
    Places osm_place_areas, osm_place_points Area (centroid) + Point mview_place_points_centroids_z0_2
    mview_place_points_centroids_z3_5
    mview_place_points_centroids_z6_10
    mview_place_points_centroids_z11_20
    Transport osm_transport_areas, osm_transport_points Area (centroid) + Point mview_transport_points_centroids_z14_20
    Other osm_other_areas, osm_other_points Area (centroid) + Point mview_other_points_centroids_z14_20
    Landuse osm_landuse_areas, osm_landuse_points Area (centroid) + Point mview_landuse_points_centroids_z10_11
    mview_landuse_points_centroids_z12_13
    mview_landuse_points_centroids_z14_20
    Buildings osm_buildings, osm_buildings_points_named Area (centroid) + Point mview_buildings_points_centroids_z14_20
    Amenity osm_amenity_areas, osm_amenity_points Area (centroid) + Point mview_amenity_points_centroids_z14_20

    Filters and Transformations

    • Name requirement: All centroids include only features where name IS NOT NULL AND name <> ''.
    • Area threshold: area > min_area, configurable per zoom level
    • Centroid computation: ST_MaximumInscribedCircle(geometry).center
    • Area field for tiles: ROUND(area)::integer AS area_m2 for land_ohm_centroids which is the bounduaries we manage it as area_mk2
    • Simplified data: Points have NULL AS area_m2 to reduce vector tile size
    • Indexing: GiST on geometry, uniqueness on (osm_id, type) or (osm_id, type, class)
    • Zoom-level optimization: Zoom levels for certain layers have been reduced based on map style usage.

    I haven’t removed the points and centroids layers yet, as the map style hasn’t been updated. This is to avoid breaking the current map style.

    This is currently running in staging: https://vtiles.staging.openhistoricalmap.org/

    cc. @tsinn @1ec5

  12. 1ec5 commented on May 19, 2025

    @1ec5
    Member

    Sounds good at a glance. place=* is a tricky one because there are a few exceptions like place=square. Fortunately, place=square areas are correctly showing up in place_areas on staging.

  13. tsinn commented on May 19, 2025

    @tsinn

    I've been reviewing today, and testing in Maputnik with the staging tiles. I'm curious about the landuse points - the landuse_points_centroids are not pulling in all of the landuse_points and landuse_areas_centroids. But they should be, right? And landuse_points_centroids should be replacing both of those individual layers in the style JSON? That was my understanding. Here's an area to review: https://vtiles.staging.openhistoricalmap.org/#15.38/50.47062/30.513213 and seen in the screenshot below. Note that I changed the color of landuse_points in the screenshot to make it easier to visually differentiate.

    Image

  14. Rub21 commented on May 19, 2025

    @Rub21
    MemberAuthor

    @tsinn

    the landuse_points_centroids are not pulling in all of the landuse_points and landuse_areas_centroids. But they should be, right?

    you are right, it should get from landuse_points and landuse_areas_centroids, I will check that

  15. Rub21 commented on May 19, 2025

    @Rub21
    MemberAuthor

    For example, in this case, both points are extracted from the same polygon, both represents same area but they are offset. They should appear in the same position since I’m using the same function to get the centroids. (ST_MaximumInscribedCircle(geometry)).center AS geometry
    https://vtiles.staging.openhistoricalmap.org/#19.51/50.4687089/30.5082334

    Image

    landuse_points_centroids landuse_areas_centroids
    Image Image

    I found this fro google search:

    The ST_MaximumInscribedCircle(geometry).center in PostGIS finds the center of the largest circle that fits within a given geometry, including polygons. The centroid of a polygon is the center of gravity of that polygon, and while they are related, they are not always identical, especially for non-regular polygons.

    There could be some variation when PostGIS is generating the centroids, since both are being generated in different functions but using the same geo function.(ST_MaximumInscribedCircle(geometry)).center AS geometry so I think it is fine for now.

    For this area,
    Image

    I had been considering only landuse points with names, but since the area contains trees, I’m going to consider all features from landuse_points.

    https://vtiles.staging.openhistoricalmap.org/#17.73/50.467829/30.519635
    Image

  16. tsinn commented on May 20, 2025

    @tsinn

    Generally, this looks very good to me. In my testing, I think I've swapped out all of the previous points for points_centroids layers in the style JSON.

  17. Rub21 commented on May 21, 2025

    @Rub21
    MemberAuthor

    Per our last meeting, a question came up about how much the tile size has increased with the addition of the new layers. I’ve been reviewing the impact after adding the new *_points_centroids layers for Places, Transport, Other, Landuse, Buildings, and Amenity. I’ve noticed that some tiles have grown by 1 KB to 20 KB, which I believe is a reasonable increase. As mentioned earlier, these new layers will eventually replace existing ones once the styles are finalized.

    https://tiler-compare.openhistoricalmap.org/tegola_interfaces/index.html#8.96/37.4316/-121.8722
    Production <-------> Staging
    Image

    cc @1ec5

  18. Rub21 commented on May 27, 2025

    @Rub21
    MemberAuthor

    The changes has been merged to production,

    @tsinn let me know when you complete the migration fo the styles to the new *_points_centroids layes, in order to remove the old ones.

  19. Rub21 commented on Jun 26, 2025

    @Rub21
    MemberAuthor

    It seems that Connor-Sebastian-S/Archive-story-map and FBLordn/DateTheMap have not implemented the migration yet. Currently, we no longer support the transport_points layer.

  20. Rub21 commented on Jul 29, 2025

    @Rub21
    MemberAuthor

    Closing this ticket since it is completed!!

  21. moved this from In Progress to Ready for Staging in OpenHistoricalMap Dev Planningon Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stylesheetstiler-imposmtiler-servervtiles

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions