tangrams / tangram-es

2D and 3D map renderer using OpenGL ES
MIT License
828 stars 240 forks source link

MapController::getPosition return LngLat with negative Longitude #1097

Closed westnordost closed 7 years ago

westnordost commented 8 years ago

Tangram-ES Version 0.4.5

MapController::getPosition and MapController::screenPositionToLngLat may return a LngLat in which (at least) the longitude is negative.

I got this above Hamburg, when having the map centered at lat=53,58220643220753, lon=9,939129168887803. Lon was -350.0608708311122 instead.

I know this is still mathematically correct, but having a coordinate whose longitude is not within the -180°..+180° bounds is certainly unexpected. If you intend to not fix this by normalizing the angle, it would be good if this were documented.

matteblair commented 8 years ago

Oh, haha that's fair. It's probably more convenient for everyone if we return longitudes within (-180, 180] and say that in the documentation for the getter.

westnordost commented 8 years ago

Fun fact: My app made lon=-350.0608708311122 into lon=_7_9,939129168887803 until I fixed this bug right now https://github.com/westnordost/osmapi/commit/16691490a7be8a187fde052d6db0b3e1f1ff316f :-D

ac87 commented 7 years ago

I should point actually not wrapping allowed had a side effect of allowing lines to be drawn across the international dateline. Since I raised a duplicate bug on the exact issue addressed here perhaps I should have added this before

See this freehand drawing example (just me drawing a random wave):

Before fix 2017-09-26 14_30_42-clipboard After fix 2017-09-26 14_28_28-clipboard

I know this fix is better for most scenarios, but maybe some applications will want to work as before. At this point I'm still just playing with Tangram-es to see what can be done. Freehand drawing works pretty well with markers.

tallytalwar commented 7 years ago

@ac87 thats a valid argument, maybe we can expose the API such that the user has the flexibility of getting a wrapped longitude or an unwrapped longitude (controlled by a boolean)? And by default we always return wrapped longitude.

matteblair commented 7 years ago

I don't think it will be helpful to add an option for getting an explicitly "unwrapped" longitude, as this concept isn't guaranteed to be preserved if we change the implementation of world-wrapping. Lines with segments that cross 180 degrees longitude will be correctly displayed using a MapData instance, so I'd recommend using that for cases like this.

ac87 commented 7 years ago

I'm not sure a drawing use case works with MapData or at least I haven't seen something dynamic enough to allow variable thickness and any color. I do appreciate the world-wrapping situation though, its currently not ideal with markers, without a jump to my location button taking you to the 'primary' world you can get lost.

Actually having thought for a minute longer I suppose a color set and set of thicknesses could be defined in YAML then drawing could work with MapData.