Repository navigation
Description
A boundary that changes often results in many overlapping features in the vector tiles that are mostly redundant to each other. For example, a tile containing San José, California, weighs in the tens of megabytes, even though it contains little besides boundaries: #698 (comment). San José might be an outlier in terms of the sheer number of annexations,1 but we can expect more problem spots in the future, particularly as mappers begin recording land swaps along river boundaries, which are complex to begin with.
The overlapping boundaries inherently come with exorbitant size overhead, even if we simplify the geometries aggressively: #702. For a sense of scale, the boundary polygons representing San José over time currently contain a total of 2,444,653 separately encoded coordinates, whereas a corresponding set of boundary polylines would contain only 69,674 separately encoded coordinates, since concurrent boundary edges would be encoded only once. Boundary edge polylines also require much less effort to render on the client side than full polygons.
Some of this redundancy is necessary, since a given edge might run in opposite directions after applying winding order to each boundary. In lay terms, along a given north–south boundary edge, San José might lie to the west of the boundary in one year but to the east in another year. A rigorous solution like #603 would probably have to address this problem comprehensively, but for now we could either defer boundary edge labels or find a way to keep two distinct linestring features running in opposite directions.
A polygon representation of boundaries has some utility, especially for rendering boundary halos of different colors, for example when a national park abuts an administrative boundary. It’s also essential for making a choropleth map out of administrative areas: #700. However, overlapping polygons make it impossible to reliably style boundaries as dashes: openmaptiles/openmaptiles#1604 (comment). For example, if we were to reintroduce dashed lines of different lengths based on admin_level=*, the dashes would clump up together forming a solid line whenever a municipal boundary runs concurrently with a county or state boundary.
A naïve approach would be to replace existing usage of ST_AsMVTGeom with whatever we did in OpenHistoricalMap/ohm-deploy#89 to copy the details of an associatedStreet relation onto the member ways. We’ll also need to generate centroid point features for these boundaries at the same time: #543 (comment). But we won’t be able to encode any side-dependent attributes, such as names, until we copy each polyline feature once per winding order.
Footnotes
-
1,174 distinct iterations for San José, compared to only 891 for Columbus, Ohio, another major city that experienced sprawl. ↩
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Production
Activity
danrademacher commentedon Mar 6, 2024
Interested in thoughts from @Rub21 and @batpad on this, especially paired with #702. To me, on-the-fly replacement of polygons with lines and the generation of centroids for labels seems like it might become overly complex, but admittedly I'm beyond the limits of my understanding of what sorts of Postgres queries we can include in our TOML file without hitting some sort of query limit.
Rub21 commentedon Mar 8, 2024
The idea of converting polygons into lines sounds promising; it will significantly reduce the size of many tiles, and for long-term efficiency, that would be beneficial to me as well. However, I believe this adjustment needs to be made during the data loading process into PostGIS, rather than within the tiler. Therefore, it should be modified in imposm by changing a parameter to load lines instead of polygons for certain types of tags.
To achieve this, we can initiate the process by copying the tile-imposm directory into ohm-deploy/images. This approach allows for better customization without altering the existing functionality in osm-seed.
For clarification, is the central point intended to be added specifically for administrative boundaries? There will be two cases: if the administrative boundaries are polygons and relations. In the case of relations, they may already contain points within them. However, for polygons, we need to add a center point. Adding a central point could be challenging using imposm, but we could explore other alternatives such as a PostGIS function to create, delete, or update center points for polygons
1ec5 commentedon Mar 8, 2024
Yes, automatically generating a centroid point is important, for more than just boundaries: #543 (comment). For boundaries, we’re already working around the issue by manually mapping and styling explicit points near the centroids. So I think we can pursue that optimization in parallel.
jeffreyameyer commentedon Apr 30, 2024
@Rub21 - any update on this?
Rub21 commentedon May 1, 2024
@jeffreyameyer , Per voice call with Sanjay and Dan, we agree that generating the center-point for each polygon or relation that comes from OSM may be challenging. The process of adding, updating, and removing a center-point is not currently supported by IMPOSM. Apart of that, converting those boundaries into linestrings may affect names styling. we can chat bit more about it.
1ec5 commentedon May 2, 2024
Are you sure the centroid point needs to be generated by imposm3? Can we instead generate it on the fly in one of the PostgreSQL queries in the tiler’s providers? For example, the
landuse_pointsprovider would query theosm_landuse_areastable, calling a PostGIS function such asST_Centroidinstead of just regurgitating thegeometryverbatim.Yes, generating the centroid points is a prerequisite for representing boundaries as lines.
To get the performance improvements, another important step would be to either join the boundary relations to deduplicate their LineString geometries or copy the relations’ details onto the member ways at import time. imposm3 might be more of an obstacle for doing this. I think we should take a look at how OpenMapTiles implements boundaries using imposm3.
/ref #543 (comment)
16 remaining items
1ec5 commentedon May 9, 2024
Now that we’re generating separate point features for the labels, name properties on the lines wouldn’t be useful for labeling centroids anymore. They could be useful for boundary edge labels, but only if we indicate whether a name applies to the left or right side of the linestring. That would be unnecessary for now, since our styles don’t have boundary edge labels yet.
I was thinking that we could also detect that the way is part of relations that completely cover a certain time period. My example way from San José was continuously part of a boundary relation for many years, so all we need is a single linestring with the earliest relation’s
start_dateand the latest relation’send_date. I don’t know how feasible this is with the current architecture. We can track this idea in a separate issue to keep things clear.[-]Replace boundary polygons with lines in vector tiles[/-][+]Vector tiles: Replace boundary polygons with lines, add centroids[/+]vknoppkewetzel commentedon May 15, 2024
I've updated this ticket with a new name to capture it as vector tile work, and created a separate design-related ticket for the stylesheet updates (#787 )
danrademacher commentedon May 17, 2024
@Rub21 can you clarify here -- in order for @vknoppkewetzel and @tsinn to style all labels for polygons, it sounds like sometimes they need to target
place_pointsand sometimes they need to targetland_ohm_centroids. Is that correct? The two will never be part of a single layer?vknoppkewetzel commentedon May 20, 2024
I can style with them as separate but it seems like it would make sense to fold into the
place_pointsdata in the future I think?I do know some of the attributes are slightly different.


in
place_points, there is no reference toadmin_levellike inland_ohm_centroids. Inplace_pointshowever,typehas a value that is useful to know (possibly?) - the naming convention may be country-dependent, but the above example screenshots showstype=county.This means:
place_pointsAND country name data layer styling forland_ohm_centroidsRub21 commentedon May 21, 2024
How is the current flow and distribution of objects in the layers?
The
place_pointslayer consists of all objects that haveplace=*according to the OpenStreetMap wiki. This includesplace=city,place=town,place=village, andplace=hamlet. Examples of these points are:When importing to the database using tiler-imposm, a conversion from
placetotypein the attributes is performed. These were established at the beginning of the project.So, if there is a relation like this one, this relation object will be added to two layers:
land_ohm(relation/polygons), which is the area of the relation.place_points, because the relation has a point member withplace=state.What we are currently developing:
For the
land_ohm_linesandland_ohm_centroidslayers:land_ohm(relations/polygons) that are areas will be converted tolinestring, and all attributes will be copied to thelinestringand it will be represented as theland_ohm_lineslayer.land_ohm(polygons) that are areas will have their centroids calculated, and all attributes will be copied to the centroids, and it will be represented as theland_ohm_centroidslayer.Therefore, for the layers, the same object will have the same attributes in the
land_ohm_linesandland_ohm_centroidslayers.As example:
place=state(Node 2113249224). This point will be shown in theplace_pointslayer.Therefore, according to our new conversion of linestrings and centroids, we would have same object in
place_points,land_ohm_linesandland_ohm_centroids, as the comment here: #701 (comment)To resolve the issue of duplication in the
place_pointsandland_ohm_centroidslayers, we have implemented some functions in the PostgreSQL database. If there is a point member in the relation with the attributeplace=*, it will be shown in theplace_pointslayer as it currently is. Otherwise, if there is no point member, it will be shown in theland_ohm_centroidslayer. This avoids having two points displaying the same attributes.For example, the above relation and way do not have a member point with
place=*. For this reason, we are creating the centroids. Note, we need to create centroids for these objects because once we convert them into linestrings, there will be no way to show the representative names without using the centroids.https://vtiles.staging.openhistoricalmap.org/#7.14/-10.298/-78.884

vknoppkewetzel commentedon May 21, 2024
Thanks @Rub21 . Currently Country and state labels are housed in
place_points, and will in the future be housed inland_ohm_centroids?OR just "the relevant country and state created centroids will be brought into place labels"??? So
land_ohm_centroidsis everything else?In #787 I've updated a test style that shows the updated
land_ohm_linesand includes a TEST data layer with theland_ohm_centroidshighlighted in red text. I can circle back to refine those further when the centroid work is finished. Does that sound like the right next steps for me on my end?I am just trying to figure out how I am meant to style
land_ohm_centroids. :) I initially was confused to not see as many points as I expected, and then to see them referencing a variety of admin levels - but not consistently, geographically.However, if the answer is just "duplicate all admin related labels and expect to pull from both
place_pointsandland_ohm_centroidsI can do that haha1ec5 commentedon May 21, 2024
Does this distinguish between the
admin_centreandlabelroles? A member with either role would typically be aplace=*node, but we would still want to generate a centroid for the United States if it lacks alabelmember, even if the node for Washington, D.C., is anadmin_centremember. These days, I viewadmin_centreas somewhat off-topic for OHM, because mappers can indicate a “seat of government of” relationship in Wikidata; however, we have over 6,000 occurrences of this role, and I’d expect the number to increase over time due to influence from OSM.jeffreyameyer commentedon May 25, 2024
Barring the discussion above related to
admin_centreandlabelroles, given that this is now operating in production, is this ticket done? @danrademacher w00t!Rub21 commentedon Jun 3, 2024
This ticket is done, closing here!
1ec5 commentedon Jun 3, 2024
Next actions: