-
Notifications
You must be signed in to change notification settings - Fork 825
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
How to render streets with a patters that behaves similar to “polygon-pattern”? #3977
Comments
The reason why attachments are slow is most likely following. Attachments are converted to styles, for example: <Layer name="roads-fill">
<StyleName><![CDATA[roads-fill-secondary-fill]]></StyleName>
<StyleName><![CDATA[roads-fill-secondary-fill-pattern]]></StyleName>
<StyleName><![CDATA[roads-fill-primary-fill]]></StyleName>
<StyleName><![CDATA[roads-fill-primary-fill-pattern]]></StyleName>
<Datasource>
...
<Datasource>
</Layer> Mapnik is querying repeatedly the same data from the datasource for every style. There is Layer option |
The current implementation with CartoCSS attachments is per-feature compositing already. I think there was some another problem. Namely rendering order, in which all |
Ideal would be to have a symbolizer that can render such line patterns natively. It would not be so complicated to implement. Lines actually are polygons rendered with solid color. We know how to render polygons with a pattern. |
Thanks. I’ve tested this, and indeed with |
I have never encountered memory issue with |
@talaj Thanks. |
@sommerluk, I was investigating options how to render points as line caps given the information Cairo handles degenerate geometries that way. As you can read from the doc, there need to be a What do you think about it? You will need to provide the point in one of these forms:
The query would look like: SELECT ST_MakeLine(geom, geom) FROM points |
Would that mean it will work only for the Cairo backend, or also for the AGG backend? I’ve tried to use |
It means that AGG backend would be unified with Cairo backend regarding handling of degenerate geometries. It is possible to rendered |
Sounds good! (I’ve played around a little bit with this on At openstreetmap-carto we would than need support for
and
This might maybe even give us the possibility to put turning circles within the same SQL querry as roads… |
@sommerluk From my point of view, it cannot be naturally done to current line drawing code of AGG renderer. Needed changes are not balanced by marginal improvement in functionality. My current opinion is that we should look for different solution. |
Thinking about introducing PointPatternSymbolizer which would render pattern in a circle. This could be extended to arbitrary shape given by SVG file in the future. |
@talaj That sound great! |
This feature has been implemented native in #3980 for master, backported to v3.0.x. in #4004, documented in mapnik-reference which got a new npm release already. Thanks to the hole Mapnik team and especially @talaj for implementing this! Closing this issue now. |
Hello.
At https://github.com/gravitystorm/openstreetmap-carto we are trying to render unpaved roads different from paved ones.
Normally, I would avoid to ask this type of questions here on the issue tracker, but I started to write the code for openstreetmap-carto in May 2017, since than the solution is in continuous development, we have tested a lot of possible solutions, but I still struggle to have a well-performing solution. That’s why now, after one year, finally I ask here.
What is the desired rendering?
Paved roads
We want to render paved roads still like they do currently in openstreetmap-carto: with a plain colour.
Unpaved roads
Unpaved roads should however be rendered from now on with a fine, irregular-looking pattern. At this image you can see the rendering we want to get. The irregular pattern fills exactly the space that would have been occupied for a paved road. Neither at crossings between two unpaved roads nor at crossings between a paved and an unpaved road there is any visual artefact.
Further requirements
We are using round line caps for roads to avoid visual artefacts at places where OSM ways are split.
line-pattern?
The natural choise would be Mapnik’s line-pattern feature. Mapnik renders this pattern following the geometry of the OSM way, blending it at angles within the OSM way. See here for a minimalistic example. But I do not get the desired rendering because line-pattern seems to have no support for round line caps, so this leads to ugly rendering artefacts on every single angle in the line, and especially where OSM ways end. (Furthermore, we need many pattern files: one for each combination of road colour and width. But the main problem with this solution are the rendering artefacts.)
dash-array?
We could use various dash-arrays to try to get a similar visual effect. But also here, we have rendering artefacts.
polygon-pattern on line geometries?
A polygon-pattern would be the perfect solution. It is not blended at angles. It can even be aligned globally, so that on crossings of two unpaved roads, the pattern makes a smooth connection. It would also play well together with highway area rendering, which are polygons. But unfortunately it is not possible to use polygon-pattern with line geometries in Mapnik. (This would be a great feature! Something like applying an SVG pattern to a line geometry just like you would apply a colour – the pattern would only be visible where the line is drawn, and the pattern itself could ideally be aligned globally.)
Our workaround…
What is the principle of the workaround?
As there is no build-in support for polygon-pattern on line geometries, we have developed a workaround. In short:
line-comp-op: dst-out;
to the line geometries of the unpaved roads to cut holes in the rendering canvas.dst-over
behind the existing canvas.There is a short, but complete documentation available.
What’s the problem with the workaround?
We have about 10 different road colours. Reading the Mapnik documentation about comp-op, we would expect that feature-level comp-op would work on a per-feature base. Quote from the documentation:
But apparently this does not happen. What we observe is:
That’s bad for our use case. So I have worked around this problem: In our MSS code (we are using CartoCSS) I’ve created attachments. This way, the rendering rules for each road colour end up in an own attachment (all of them within the same layer). Also the fake-global-bounding-box gets its own attachments: one for each road colour, in the MSS code always directly after the rendering rules for this road colour. This leads to a perfect rendering without any artefacts. So the pull request implementing this for openstreetmap-carto had been merged.
Unfortunately, it turns out that just using many attachments makes the rendering process slower – by factor 2 or 3 measured for the whole style! Given that the whole style has also many other layers than the roads, the attachments itself will make a much greater slow-down for its own layer only, maybe factor 50? (That’s even true when these attachments do not actually get rendered because there is no data available for them in the data source.) The pull request has therefore been reverted.
My questions
If we could some help or some ideas here, that would be great – I would highly appreciate!
The text was updated successfully, but these errors were encountered: