-
Notifications
You must be signed in to change notification settings - Fork 822
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
Render “surface” tag on roads with a pattern #2640
Conversation
This code is still far from being complete. And there are many lines of code to write. And there are yet some questions. So I think it’s good to talk about these questions yet now. Disclaimer: The pattern itself and its color are currently only an example. And, yes, highway=motorway is not the best example, but it was the first entry in roads.mss… 1.) I’ve attached the pattern to
and the consequence is that, where lines starts and stops, the round line caps of one line cover the pattern of the other line: https://cloud.githubusercontent.com/assets/6830724/26347777/1e1403f8-3f9a-11e7-8fb8-d8beed89c977.png So there are some parts that stay without pattern. I’m not sure if we can do something about. There seems to be not round line caps for patterns in Mapnik. And putting the surface in its own layer would reduce the problem, but is probably complicate code, and still leaves some artefacts if the two lines are not directly strait. Is attaching the pattern to the roads fill okay? Any ideas? (In general, I think this is not nice, but we have also other rendering artefacts in other situations, so this might not be a show-stopper.) 2.) Is the coding style okay? (Naming of files with leading 0 to allow automatic file order; type of selectors…) 3.) The code seems not to work for motorway_link |
If that is the case this could indeed be a deal breaker (and my mental list of things Mapnik can't do keeps growing...). Theoretically there is of course still the option to give up and use ST_Buffer() but i don't think we will want that due to code complexity and having all the line widths etc. in SQL. Alternatively there is also ST_StartPoint()/ST_EndPoint() which could be used to separately draw the round line end caps using marker symbolizer SVGs. But overall this is likely not any less complex. Drawing all the line patterns above all the based colors could be worth trying - like you said this will lead to artefacts (both gaps and overlaps). I have not looked at the code yet and i am probably also not the best one to evaluate that because i am not really that familiar with the roads code. |
Introducing after |
I think having a separate layer for the “unpaved” pattern has this behaviour on junctions:
So: What is the lesser evil? |
You could render the base fill color of paved roads above both the base color and the pattern of unpaved roads. That would of course mean yet another level and more complexity. In total you would have (from bottom to top, not considering bridges, tunnels etc.):
There is of course the question if that is correct if you have a unpaved primary connecting to a paved secondary but that is probably fairly theoretical. |
2017-05-23 11:28 GMT+02:00 Lukas Sommer <notifications@github.com>:
1.) I’ve attached the pattern to
do you think it would be possible to subtract those dots rather than adding
them? Something like
`<Style name="eraser" comp-op="dst-out">` in carto? (adding it on the
style level)
|
Here an example with the unpaved pattern in its own layer: https://cloud.githubusercontent.com/assets/6830724/26527696/f24e5442-4388-11e7-9bdb-ffd6df5cb952.png When the way is continued, it looks good when the angle is not too extrem (violet). When the angle is very extreme, there are some artefacts (blue). When the way is split and there is some 90° angle, than there is a small part that will not be covered, and when it’s more than 90°, than this uncovered part might be bigger (green). Also at start and end points of lines there is a small part that is not covered (black). When ways are crossing, there is an overlay (orange), but it’s less extreme than expected. Overall, I think this is not ideal, but at least better than attaching the pattern to the very same street layer. |
The idea with comp-op sounds nice. I’ll try that… |
Some documentation about comp-op: https://tilemill-project.github.io/tilemill/docs/guides/comp-op/ and |
@dieterdreist Could you give some details about your proposal? What (alpha) geometry has to be substracted? |
Another layer won't work because it will fail with group-by and layering, e.g. a paved bridge over an unpaved road. You might be able to do something with attachments. Besides the technical feasibility of pattern fills, we also have to look at if we can get good cartography from them. So far I don't like the examples I've seen, but how would they look on highway=secondary and below? Most unpaved roads will be some type of road which we render as white. |
I agree with Paul that now that we know the principal technical limitations of using line patterns it would probably be a good idea to test the visual suitability before putting too much work into finalizing the technical details. Your current examples are good for showing the principal problems but practically we will need to see how problematic these are with the colors we would actually use. Since you will probably end up using a differently colored pattern for every road base color you probably can also use an SVG with a solid color background which would avoid the overlaps although the gaps and missing line ends would still create problems. |
After some time being busy with other stuff, finally I could do some work on this issue. It’s less straightforward than I thought. The above screenshots show different patterns. Lessons learned:
Comments? Which of the above patterns might be the best to continue the work? |
I think these are mostly too strong, the pattern should be strong enough to be recognizable under most circumstances, at least for the wider roads, but not any stronger. Remember this is a secondary characterization of roads behind the main classes. It is better if in some cases the pattern is not recognizable than if it hides or obscures other information. The 07 example seems fine in that regard but as you mentioned it should be color neutral for the white roads of course. For the colored roads i would probably try making the pattern background slightly brighter than the paved color and the grain slightly darker. This is not possible for the white roads of course. Something like might work for the white roads, maybe even with an even lighter color. What a grain pattern will inevitably do is making color differences between the different road classes more difficult to distinguish. In case of the white roads this mainly concerns Yes, the very thin roads will be a problem - though primarily at z<16 of course. Also need to see if the access restrictions are still properly visible with the pattern. |
On 2. Jul 2017, at 14:31, Lukas Sommer ***@***.***> wrote:
Comments? Which of the above patterns might be the best to continue the work?
did you try subtracting with dst-out rather than adding the pattern?
|
Yes, a little bit. At the first try, I didn’t understand how this works. I tried to create a new layer filled with the pattern and cut off what’s out of the road surface. It didn’t work, also because Mapnik cannot group layers. After reading the documentation, I guess it could work this way:
Is this what you had in mind? If so, I can try to make a working prototype, but this might take some time… |
sent from a phone
On 2. Jul 2017, at 19:04, Lukas Sommer ***@***.***> wrote:
After reading the documentation, I guess it could work this way:
Render the unpaved roads layer with dst-out cutting a hole where the roads fill should be.
Next, render a layer with the pattern (opaque) and use a layer rendering mode that pulls it behind the existing content.
To make this work for various road types, we need an own layer for each road type (or at least each road colour).
Is this what you had in mind? If so, I can try to make a working prototype, but this might take some time…
I thought it could work with just the first step: cut out (subtract ) the pattern from the road fill. It will only be visible over a background different than the fill color, but this should generally be a given. The basic idea is to work with the holes, not with another color that is added.
|
Pattern 11 proposed by @imagico looks good. Personally I would not go to a lighter tone, because yet right now it depends on the angle at which I’m looking to my screen if I can remark it or not. A positive side-effect of pattern 11 (compared to the previous patterns) is that, as it’s lighter, the rendering artefacts of line-pattern are less visible. |
Pattern 11 with access restrictions: |
Okay, now I understand. This would make the street colour look different depending on the ground where they are rendered above. I’m not sure if that’s desirable (especially for wood). Technically, dst-out cuts a “hole” (transparent part) in the layers below. I’m not sure if it’s possible to cut just the roads fill and the casing (which is below), without cutting the background (residential, wood…) also. |
dst-out (mentioned by @dieterdreist) could maybe help with the line-pattern rendering artefacts. dst-out ignores colours, it takes just the shape information (where is something rendered), and instead of rendering, it cuts a hole in all underlying layers (=it makes them transparent). In the final rendering, these parts show up with the colour #dddddd; which must be some sort of default. We could
I’ve done a quick-and-(very-)dirty hack, and it works.
(Anyway, I’m new to the comp-op feature and so I’m not totally sure if everything above is correct…) |
Do you feel that this code is mostly complete and sane? If yes, we could merge it as it is soon, so it would be included in the next release, which is planned on Friday. I think 1 year of work is long enough and we can tune the pattern visibility later on. |
966cd9d
to
b573d60
Compare
I’ve removed the pattern for track area. An additional argument for removing pattern for track areas: The pattern is about “surface” tag. But for track ways, we do not render the surface tag, but the tracktype tag. This would be confusing together the track area surface rendering. From my side, this is ready now. |
@matkoniecz What's your opinion on merging current code? |
I think it makes sense to move all the images into new |
Done. |
Than I would rather suggest – instead of merging it before Friday – merging it after Friday, so having it in master for some time before a release. |
Rebased. |
OK, I have merged it now, since v4.11.0 is released already. Please test it as much as possible now. @matkoniecz has not approved merging, but I think this is the right moment and if anything is seriously broken, this code can be reverted, but if there are some smaller issues (like my own concerns with pattern visibility), they should be just fixed now. @sommerluk Thanks for your work! 😄 |
I want to say “Thank you” to everyone who has contributed here (in order of appearance in the comments):
|
Earlier @imagico said “i think it would be nice if you could find the time to write up the underlying technical idea in a generic form”. Well, I’m not really good in writing documentation (especially en English), but here we go: https://github.com/sommerluk/roadpatternrendering Comments are welcome, including language-related corrections. I think we should have also at least a basic documentation here in openstreetmap-carto. Maybe in |
Looks very good. Reading over it now it seems the two nested queries to get a list of all distinct layer values are unnecessarily complex. In the original sketch the inner query was reused from the main geometry query but without doing this i think the following is more compact and should lead to the same result:
|
@sommerluk What do you think about this code now? It's reverted to make the immediate effect on performance and v4.12.1 has been released, so we can think what to do next. Would you like to update it and re-submit for merging or maybe something else would be better for you? |
@kocio-pl Thanks for bringing this up. I’ve played around with this, see #3280 (comment) for details. |
Render “surface” tag on roads with a pattern
Closes #2621 (mutually exclusive with this PR)
Closes #3083 (mutually exclusive with this PR)
Resolves #110