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

Some GeoJSON geometries break in v0.46+ #7436

Closed
mourner opened this issue Oct 17, 2018 · 11 comments
Closed

Some GeoJSON geometries break in v0.46+ #7436

mourner opened this issue Oct 17, 2018 · 11 comments
Assignees
Labels

Comments

@mourner
Copy link
Member

mourner commented Oct 17, 2018

mapbox-gl-js version: v0.46+
browser: any

Link to Demonstration

  1. Test case by @samfader https://bl.ocks.org/samfader/raw/0c68b85662ecb933bc5cbcfb7a673cfc/
  2. Test case by @anisart https://codepen.io/anisart/pen/wYpwpb

Expected Behavior

Shapes look the same on all zoom levels.

Actual Behavior

Important vertices are dropped on some zoom levels.

Reported in comments to #7023.

@mourner mourner self-assigned this Oct 17, 2018
@mourner
Copy link
Member Author

mourner commented Oct 17, 2018

Bisected to 4fd646c, digging into geojson-vt now.

@anisart
Copy link

anisart commented Oct 17, 2018

I tried to charge order and direction of points in polygon. It stopped breaking when I set polygon from top-right point. But it doesn't help in all cases.

@mourner
Copy link
Member Author

mourner commented Oct 17, 2018

It's likely caused by mapbox/geojson-vt@7226705, — I'll look closer why that happens and submit a fix tomorrow.

@samfader
Copy link
Contributor

@mourner is it possible that this change might be causing a new issue - namely, lines of polygons are faintly visible in polygons themselves? See my test case:

https://bl.ocks.org/samfader/d1c9ab411d04bc82093c25cc80c55103

Here is the same data rendered as type line so you can see that those lines are still being rendered under the polygons: https://bl.ocks.org/samfader/39bc8e61c4b63f7739e75277fc40c554

Let me know if a new ticket is in order here.

@mourner
Copy link
Member Author

mourner commented Nov 14, 2018

@samfader maybe it was "working" before accidentally? The behavior looks like something I'd expect — to guarantee gapless rendering, you'd use a buffer in the tile data.

Also, let's confirm that it's related to the geojson-vt issue by checking in both v0.50 and v0.44.

@samfader
Copy link
Contributor

samfader commented Nov 14, 2018

@mourner apologies, I'm not sure I completely understand what you mean. Do you mind expanding on how this is expected behavior?

That being said, it looks like you're right that it's not related to the geojson-vt issue, because in v0.44: https://bl.ocks.org/samfader/ced01c4609da3979be1922f9b01740f6

Still seeing the lines. So I think I just need to get a better understanding of why this is expected given the data I have. Let me know if there is a better channel for this!

@mourner
Copy link
Member Author

mourner commented Nov 14, 2018

@samfader if you set fill-antialias: false in the layer paint properties, the lines disappear. You can look at antialias as a sort of a polygon gradient stroke.

As far as I understand (@ansis correct me if I'm wrong), if it's drawn on the tile boundary (there's no buffer), only half of it is clipped, and another one produces those subtle lines. This is the consequence of having buffer = 0 in the data, so I think it's working as designed. The proper fix is to add a buffer to the tiles, and a workaround is to disable antialiasing (although this will make polygon edges look slightly less nice). Perhaps updating our fill antialiasing algorithm somehow would fix this issue (e.g. only draw smoothed pixels on the "outside" of a polygon), but we probably shouldn't spend time on this.

@samfader
Copy link
Contributor

Got it, thanks so much @mourner!

@ansis
Copy link
Contributor

ansis commented Nov 15, 2018

I think buffer=0 should still be fine for gapless polygons because the lines are drawn on the outside and the inside part should be clipped away. That said, I'm not surprised this is buggy. @samfader I'm not seeing any lines or gaps in the example you posted. Could you provide a screenshot of what you are seeing?

@mourner
Copy link
Member Author

mourner commented Nov 15, 2018

Here's what I'm seeing on my retina MBP (in Chrome, FF and Safari):

image

If you pitch the map or rotate it far enough, the lines disappear.

@samfader
Copy link
Contributor

@ansis see screenshot above, but also my apologies since I modified my example and forgot to change it back. You should be able to see the lines in this test case: https://bl.ocks.org/samfader/d1c9ab411d04bc82093c25cc80c55103

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

No branches or pull requests

4 participants