tangrams / tangram-es

2D and 3D map renderer using OpenGL ES
MIT License
826 stars 238 forks source link

Polyline issues #1655

Closed rwrx closed 7 years ago

rwrx commented 7 years ago

I have noticed that when I add polyline on map using method MapController.addMarker() that polyline stops beign rendered on zoom 16 and higher. I have tracked it down to polylineStyle.cpp file to method PolylineStyleBuilder<V>::evalWidth() it seems that when width is getting smaller and smaller it looses precision and polyline simply disappears. However I am not sure if this may be the issue. Maybe this is correct and issue is in rendering.

Also I have noticed limitation for count of points which will be drawn for polyline. For example when I try to show polyline with for example 40.000 points it shows roughly first 10.000 points and others are not shown. Is this known behavior? If not how can this be resolved?

Thank you.

Buthrakaur commented 7 years ago

I'm facing the same issue - I initially thought it's related to order, but the problem didn't disappear when I increased polyline order to 3000. The polyline is correctly visible until I zoom in over 20 - it disappears when I reach zoom 20. I must zoom out to 19 to get it visible again.

bug repro

Buthrakaur commented 7 years ago

This is probably related: https://github.com/tangrams/tangram-es/issues/1463

rwrx commented 7 years ago

Yes, when I was debugging it I have found out that it is probably due to float precision. But I am not sure how to solve this problem correctly.

tallytalwar commented 7 years ago

Thanks for debugging this @rwrx.

Yes all of you are correct in concluding that this is a floating point precision issue, when a polyline marker spans a large geographical area. As mentioned earlier in the comment from @Buthrakaur its earlier reported in #1463 and #994.

Its not a trivial issue to resolve because of how marker construction is implemented on top of the tile construction/rendering pipeline. However, as suggested in #1463, I would recommend to use ClientDataSource interface we provide to draw any user geometry which spans a large geographical area. The ClientDataSource interface does not run into this issue, as it splits the marker geometry in apt tiles internally and hence does not exhibit this precision issue as the splitted geometry is bound within the tile bounds.

I am marking this issue a duplicate and closing in favor of #1463 and #994. Will keep an eye on this to budget for this work in our next quarter.

Apologies for not getting it fixed for a while now! :|

Buthrakaur commented 7 years ago

Thanks for explanation @tallytalwar . Is there any precise definition for "large geographical area"? We use polylines to draw walking routes, which are generally 1-10km long and quite often face this issue. I wouldn't call this "large geographical area" though... :)

Buthrakaur commented 7 years ago

@tallytalwar just a question to

I would recommend to use ClientDataSource interface we provide to draw any user geometry which spans a large geographical area.

Why isn't this used internally for polylines to fix this bug systematically instead of applying workarounds?