mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

CoordinateBounds incrorrect across antimeridian

Open purdyk opened this issue 2 years ago • 1 comments

Environment

  • Android OS version: Android 13 ( API level 33 )
  • Devices affected: All tested
  • Maps SDK Version: 10.8.1, 10.11.2

Observed behavior and steps to reproduce

  • When attempting to set the camera to bounds spanning antimeridian, the opposite span is produced

Expected behavior

  • The western longitude is at the left of the map and the eastern longitude is at the right of the map.

Notes / preliminary analysis

I am filing this against android as i'm currently developing on android, but I suspect this issue is lower in the native code. I did not file the issue against the archived native repo, but am happy to do so.

( the following coordinate pairs all list longitude first )

We're producing a CoordinateBounds model with the following properties:

southwest: coordinates=[170.169374, -43.422486]
northeast: coordinates=[-73.97631659, 47.25437754000001]

Note that southwest is in New Zealand and northeast is in Quebec

CoordinateBounds.crossesAntimeridian() incorrectly returns false.

Further investigation gives us the following center values:

Camera center ( from cameraForCoordinateBounds() ): Point{type=Point, bbox=null, coordinates=[48.60561894499986, 2.1347870554087365]}

CoordinateBounds center: Point{type=Point, bbox=null, coordinates=[48.60561894500001, 1.5311597350000028]}

Our calculated center: -131.394381, 1.53116

Additional links and references

Here are the results of setting these bounds: incorrect

Here is roughly the request bounds: correct

purdyk avatar Mar 10 '23 18:03 purdyk

hi @purdyk , this is an expected behaviour. all coordinate bounds calculations are done using a single world copy. crossing antimeridian is treated as another copy of the world.

ank27 avatar Apr 14 '23 10:04 ank27