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

Mixed winding order confuses MapNik renderer #11

Closed
pramsey opened this issue Jan 7, 2016 · 6 comments
Closed

Mixed winding order confuses MapNik renderer #11

pramsey opened this issue Jan 7, 2016 · 6 comments

Comments

@pramsey
Copy link

pramsey commented Jan 7, 2016

The complex polygon in this KML file has a mixture of winding orders, which cause MapNik to render the holes as filled (one hole is probably reversed relative to the others).

screenshot_09

When the polygon is "fixed" by using ST_ForceRHR on it, it renders correctly (as seen above).

@pramsey
Copy link
Author

pramsey commented Jan 7, 2016

Open question is whether it's worth fixing. The workaround is clear, and not too expensive in cases where this manifests, just wrap the geometry in ST_ForceRHR. Checking for this in every render would add overhead that would only yield an improvement in extremely rare cases (though I suppose the since the check would only be required in cases where # holes > 1 the check itself would only get run infrequently). However, orientation checking is not cheap (basically you calculate area and see if it's positive or negative).

@pramsey
Copy link
Author

pramsey commented Jan 7, 2016

As a proof of the point, I was able to generate the same effect by creating a polygon with two holes, one clock-wise and the other anti-clock-wise.

screenshot_10

@pramsey
Copy link
Author

pramsey commented Jan 7, 2016

Actually, the problem seems to be having the exterior and interior rings with the same order. These rings all go anti-clockwise. So MapNik expects holes to always run counter to hulls? That seems like a big assumption, in a world of ugly data.

screenshot_11

@pramsey
Copy link
Author

pramsey commented Jan 7, 2016

This was canvassed in mapnik community https://github.com/mapbox/tilemill/issues/2110#issuecomment-75897323 and a fix applied mapnik#2371 (comment)
(maybe to the 3.x branch)

@pramsey
Copy link
Author

pramsey commented Jan 7, 2016

For @rochoa to review. It's tiny, but it's really deep in the stack, could have some unexpected effects in unexpected places.

@rochoa
Copy link

rochoa commented Jan 12, 2016

Unexpected effects in unexpected places sounds like a doble negation, so ... what could go wrong?

@rochoa rochoa closed this as completed in c355c88 Jan 13, 2016
rochoa pushed a commit that referenced this issue Jan 13, 2016
Fill polygons irrespective of winding order (closes #11)
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