Skip to content
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

Draw in relations #13

Open
bovis opened this issue Mar 8, 2023 · 5 comments
Open

Draw in relations #13

bovis opened this issue Mar 8, 2023 · 5 comments

Comments

@bovis
Copy link

bovis commented Mar 8, 2023

I'd like to draw in a primary waterway, like a river, and large land areas, like a county or state. Is drawing inside a relation possible?

In the basemap rules file, this does not appear to have any effect:

<relation>
<tag k='waterway' v=''/>
<tag k='_action_' v='draw:color=blue;bcolor=black'/>
</relation>

@rahra
Copy link
Owner

rahra commented Mar 9, 2023

Well, it depends. The topic is more complex than it looks like.
Draw() does draw lines along ways and/or fill polygons (closed ways).
If applied to a relation it will draw lines along all ways found in the relation but it cannot simply fill because that is something which could be defined in several ways.
If you want to fill a polygon which is defined by a set of ways which are grouped by a relation, you would first have to do a cat_poly() on the relation. This connects all ways to a single closed way (if possible).
Then in a second step fill it.
Note that in that case you have to add a higher version to the way rule because of the execution order.
You could do something like data. But I don't know how exactly your data is tagged so maybe it needs some adaption.

<relation>
   <tag k='waterway' v=''/>
   <tag k='_action_' v='cat_poly:no_corner=1'/>
</relation>
<way version='10'>
   <tag k='waterway' v=''/>
   <tag k='generator' v='smrender'/>
   <tag k='_action_' v='draw:color=blue;bcolor=black'/> 
</way>

@bovis
Copy link
Author

bovis commented Mar 12, 2023

Thanks, @rahra

This works, but the functionality is difficult to manage. It generates a lot of triangles where you might expect circles or rounded rectangular shapes. I think the problem may be with the ordering or direction of ways. According to the manual: "The insertion of artificial ways only works properly if the ways have a specific direction."

@rahra
Copy link
Owner

rahra commented Mar 13, 2023

Yes, this may be the case.
Unfortunately, you stumbled on a big mess within the OSM data. Larger objects have no defined directions (except for the coastline) which creates a lot of problems and headache for every renderer.
Can you share a sample output and sample input data that I can have a look at it?
Probably I can find a solution or at least point out the problems and possible solutions.
Creating really cool maps does rarely work out of the box if the data is a mess, for every renderer, not just Smrender.

@bovis
Copy link
Author

bovis commented Mar 14, 2023

[EDIT 2023-03-15 formatted HTML and decreased image display sizes]

There are two situations that seem common that would probably get things started. I'm happy to learn how to edit the OSM data or smrender to fix these and similar issues.

This output comes from smrender's default rules except where I've noted.

Hackensack River:
https://www.openstreetmap.org/export#map=15/40.8061/-74.0384
https://overpass-api.de/api/map?bbox=-74.0606,40.7980,-74.0171,40.8188

The first image I've attached here shows that the river is only filled with blue to a certain point. It should continue upstream, northward in the image. Blue lines at the centerpoint of the river highlight where it goes, but the full width isn't being filled like it is on the left side of this image.

My output (hackensack-river.txt) addresses a few errors, but none of the data errors it mentions appear to be part of the river. They are part of a wetland.

Morris Canal Basin:
https://www.openstreetmap.org/export#map=16/40.7112/-74.0415
https://overpass-api.de/api/map?bbox=-74.0548,40.7077,-74.0307,40.7150
https://www.openstreetmap.org/relation/2788561

You can see in one image that the basin doesn't get filled with blue. The blue you see is a boatyard.

If you enable the following rule, you get what's pictured in the second image. An outline is drawn there of the basin.

<relation>
<tag k='natural' v='water'/>
<tag k='type' v='multipolygon'/>
<tag k='_action_' v='cat_poly:no_corner=1'/>
</relation>

A comment in the rules file says this will break other cat_polys. It does, clearly. What it doesn't do is fill the relation in a way I expect.

I've tried addressing this relation with different tags, and I always end up with a similar result. It looks as if the relation is cat_poly'd into a shape that mirrors the outline of the area. Like it starts from Point 1, goes in order to point N, and then circles back to Point 1 again one pixel parallel to the line drawn in the first direction.

In the OSM data, there are two ways that comprise the basin -- an outer that's most of the basin inland, and an outer that's also a coastline. It seems as if cat_poly never traces the coastline part. It doubles back on the inland part.

My first output (morris-original.txt) gives no rendering errors. My second with that relation edit (morris-withrelationrendering.txt) mentions the ways 179058314 and 207411156 as possibly having the wrong direction. Those ways are part of the basin's relation.
hackensack-river.txt
morris-original.txt
morris-withrelationrendering.txt

Hackensack River:

Morris Canal Basin:

Morris Canal Basin (with relation rendered):

@rahra
Copy link
Owner

rahra commented Mar 20, 2023

Hi!
Sorry that I didn't reply yet. I'm working on 10 projects at a time...
I'm pretty sure that I had the same issue some years ago. I'll look at your data and will point out a solution.
Bernhard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants