-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rendering for straits mapped as linear ways #3733
Conversation
North Inian Pass, Alaska - example with a ferry following the center of the strait. The text style and color is different, so there should not be confusion. https://www.openstreetmap.org/#map=14/58.2839/-136.3820 z14 after - shows larger strait text labels at z14, and contrast with ferry text labels. |
Strait of Magellan
z8 after - Strait of Magella and Cascada Channel z9 after - Cascada Channel and other straits. (The "senos" could also be tagged as natural=bay, & bay=fjord) z10 after - Strait of Magellan (northeast portion) - also labeled is a segment called "Second Narrows" (Angostura Segunda) |
I would be against rendering straits in a way where the mapper can decide on if and how the strait is shown by changing the length of the way - same reason as with use of way_area with polygons. And as i like to say: The typical strait between two convex coasts is a one dimensional feature, it does not have a length, it only has a width. I see three reasonable possibilities to render linear ways representing straits without taking the coastline into account:
https://www.openstreetmap.org/#map=14/-0.1787/130.2420 |
This is easy, but often the labels will be oriented quite wrong. For large straits it's no problem, but for narrow passages it could make the label seem out of place
This seems unnecessarily complicated, compared to the option below, and will not provide optimal results when the strait is narrow and curving.
Does this mean repeating the label after 800 pixels (at higher zoom levels) as shown above, or should it only be rendered once, no matter the zoom level? It sounds like you want the initial zoom level to be limited to z14? Mapnik normally will not place a label along a linestring if the length of the linestring is less than the size of the label, but this will only prevent the label from showing if the line is too short at the minimum zoom level, so I imagine that this is acceptable. There are few straits short enough at z14 for this to present a problem.
I don't see any nodes, ways or multipolygons in any of those three areas that are tagged with natural=strait or =bay? But I've added some fictitious labels for test rendering. Are you saying that the 15 point label would be too wide for the narrow passages in these examples at z14? River labels are 12 points at z14 and below, so I could change it to this width. z14 Raja Ampat Islands, West Papua - 10pt font for straits (polygons on left, way on right, node below) z14 SW Phillipines very narrow - 12pt font
Same strait, labeled on center point without rotation. Poorer cartography: |
Note i don't want to dominate this discussion - i think it is important for others to weigh in and communicate their opinion on this matter. It is a topic that goes somewhat beyond the particular change here because it is about how to best render features that can be and are validly mapped in different ways by mappers. For cases of different tagging we have a consensus position on this of the project (the 'non-proliferation' principle w.r.t. new synonyms for established tags) but for different geometric modelings we don't have anything comparable.
Since the label is not oriented but plainly horizontal it is not wrong, it is just not indicating the orientation of the actual strait with the way it is drawn. The aim here is not how to draw the best map with the least effort for the developer because then the answer is obviously to have the mapper draw the label. The question is how to formulate the rules to create constructive feedback to the mappers on their work in documenting the geographic reality. No matter what design approach you use my aim would always be to try not rendering the same thing differently depending on how it is mapped without there being a constructive message communicated in this. If the reason for rendering things differently because rendering them identically based on either node, linear way or polygon is too difficult without sacrificing quality i would sacrifice quality before creating wrong incentives (which speaks strongly for the first option). Because our inability to equally label straits mapped with nodes, linear ways and polygons with an oriented label is just our technical inability and not due to necessary information being missing in the data. But as already said the other approaches seem reasonable ideas as well. I talked about essentially the same problem using the example of waterway=dam/waterway=weir recently by the way at FOSSGIS - in German though so it is not that accessible for everyone: https://media.ccc.de/v/fossgis2019-457-wenn-mapper-karten-malen
I don't see a particular problem in repeating labels.
If you don't want to make decisions based on way length and lack any other importance rating information you have to choose a relatively late starting zoom level. For bays this is z14 so it makes some sense to use approximately the same for straits. That Mapnik does not show line labels beyond the extent of the linestring is a problem since (a) the way length comes in again as a deciding element for the starting zoom level and (b) showing/not showing a label will confusingly depend on the length of the name and both without the source geometry of the decision being actually visualized in the map. You can of course go and use SQL code to extrapolate the way to the needed minimum length in both direction to deal with this problem but that would add a lot of complexity. This is mainly why i mentioned the second possibility of oriented point labels. You can also choose between these options based on way length but as you mentioned if you because you don't have a suitable importance rating use a rather late starting zoom level the problem is not really that significant practically. |
Based on your suggestion, I went back and checked how nodes are rendered. It's quite different than polygons currently; they are only shown from z17 which is quite late (isolated dwellings, farms and "localities" are shown at z15), and the font size is always 10 pt. I'll plan to have the nodes and ways render in the same font size and style after this PR. [Also I notice that bays are rendered in a different font when tagged on nodes; this needs to be fixed.]
In that case, I will try having them repeat every 400 pixels, the same as rivers. This helps show the geometry of the way on higher zooms, and helps confirm that it is mapped correctly. It's analogous to the river labels in a large river or estuary.
Can I confirm that the database is not imported with a field like
I believe that orienting the direction of the labels based on a point text placement would also require too much complexity. I've been researching the minimum zoom level that would be most appropriate for nodes and ways; see the next comment. |
Also text size is changed to 10pt at z13 and 12pt at >=z14 for ways and nodes tagged as straits
Here are examples with the latest commit: North Inian Pass, Alaska (no longer rendered at z10 to z12) Lilleboelt, Denmark - a long, curving strait Selat Bali, Indonesia - 2 straits mapped as nodes Selat Lumut, Malaysia - (Hey, today you learned that "selat" means "strait" in Malaysian and Indonesian! They are both dialects of Bahasa Melayu) Mboli Passage - (From above, listed as one of the straits that is a little too narrow at z13): |
Yes, for linestring length you have to use ST_Length(way). But keep in mind that a way can only have a maximum of 2000 nodes and most straits mapped with linear ways only have a few nodes. So this is not really that expensive. It could be advisable to exclude route relations (i.e. only allow osm_id > 0). If you don't really need the exact length (which you don't because you don't know the exact size of the label in rendering anyway) you can also work with the bounding box size instead.
Yes, you could do that - but you would need to make sure that even for very long names the label does not vanish when switching from point to line labeling as you zoom in because Mapnik does not fit it on the way.
I am not sure if the complexity is actually larger than what you need for the above. Regarding size and zoom level thresholds: Keep in mind that:
|
OK, perhaps I guessed wrong about how it would be done, I haven't learned much about SQL yet. I was thinking that a longer linestring would have to be generated, e.g. as in your code for fords in But if there is a way to determine the approximate orientation of the way in the SQL, then we could create a column with this value, and use it with |
For rotated point labels you could do something like:
Or - since you'd probably use it for small scales where the length of the way is small relative to the size of the label you could also simply estimate the orientation from ST_StartPoint() and ST_EndPoint(). Practically it is a bit more complicated since you want to avoid upside down labels. There are other options like constructing a line geometry based on this orientation (ST_Rotate()/ST_Translate() are useful for that). Anyway - as your tests also show - the real problem is importance rating and that is not reasonably possible without pre-processing. So it is of rather limited use to invest a lot of work in designing a sophisticated labeling logic that lacks this fundamental prerequisite. At the moment i see two relatively simple approaches therefore (but would be open to other suggestions):
I think for the second approach the starting zoom level constraint is harder because it is less intuitive to the map user why a label might be missing. |
Sorry - mistyped, that should have been:
I have never used text-orientation so i am not really sure what is happening here but as said you'd need some additional logic to avoid upside down labels. Regarding starting zoom level - you should keep in mind that z13 in southern Norway is the same scale as as z14 at the equator. And as said starting too early would incentivize against mapping straits as straits. Regarding your concrete changes - what you changed in the labeling logic for the polygons does not make much sense to me. As written in other context before - i think if you want to change the polygon labeling you should remove use of way_area.
That depends on how much effort you put into this. Generating a directed labeling geometry from either linear ways or nodes is perfectly doable but of course more complicated than a simple distance to shore based importance rating. |
Ok, now it works with The results of The values of the angles are also not exactly as expected, probably because we are rendering in mercator and the azimuth calculation is based the geometry on the surface of globe. It appears we would need to:
Sounds like too much trouble for only linear ways, but it would be nice to solve for nodes once we have preprocessed data, so I've recorded these thoughts for posterity, in case it is possible. |
Also separated out CSS for natural=strait points so that zoom level could be set separate from polygons
The problems in Norway seem related to the extensive areas of fjords and small islands created by glaciation, which is not as prevalent near the equator. I'm also concerned that showing straits only on high zoom levels will discourage mappers from adding larger straits, because the labels will be hard to see. However, I will change the initial level to z14.
I did not intentionally do this for polygons, but I see now that adding |
Regarding label rotation - all operations are done in projected coordinates, you don't have to consider that. Point 2 and 3 look right. The point of this as mentioned would be to allow labeling straits mapped with a linear way with a directed label at scales where the way itself is not long enough to place a line label. This is a relatively small window (usually probably just one zoom level).
Right now - without changing the way_area logic for polygons - this style loudly screams at mappers to map any strait or bay with a polygon with the size representing cartographic importance. As long as this is the case smaller subtleties in starting zoom level will not have much influence on mapping with nodes and linear ways. But apart from that - we have for many years rendered bays starting at z14 and this did not have a negative effect in that direction apparently. Most of the large bay polygon drawings added recently were replacing node based mapping and were not newly mapping things not previously mapped. But if you truly think z13 is safe even in densely mapped areas near the equator i would be fine with that. You have looked at this more in depth than i have. |
It's okay to set the initial zoom level to z14 for now. Once we have a way to calculate an importance / size for nodes, then we can reconsider the initial zoom level for linear ways as well. |
I believe this PR is ready for review / merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine.
One problem i noticed but that is not specific to straits and therefore does not need to be fixed here is that when a node is double tagged natural=strait + place=locality (which is fairly common) it starts at z14 with the strait styling but switches to the place=locality styling at z15 since the placenames layer has priority over the amenity-points layer. I think labeling of place=locality should be moved to amenity-points and - like the rest there - needs to be prioritized according to starting zoom level.
Partial fix for #3634 and related to #804
Follow up of #3438
Changes proposed in this pull request:
Explanation:
Test rendering with links to the example places:
Bering Strait, between Alaska and Russia
https://www.openstreetmap.org/#map=9/65.7046/-169.0192
z7 before = after (unchanged because the way is less than 100 pixels long at this zoom level)
z8 before
z8 after
z9 before
z9 after
z10 before
z10 after