mapillary / mapillary-python-sdk

A Python 3 library built on the Mapillary API v4 to facilitate retrieving and working with Mapillary data.
MIT License
39 stars 15 forks source link

[Utility] International dateline check for bbox #39

Closed cbeddow closed 2 years ago

cbeddow commented 3 years ago

Is your feature request related to a problem? Please describe. Related to #27

If a bounding box crosses the international dateline, then checking if an image/map feature point falls inside the bbox could fail.

For example if the bbox of [west,south,east,north] is: [174.375,-20.879342971957897,-169.5849609375,-11.566143767762844]

And a point is located at: (178.5498046875,-17.936928637549432)

Then the longitude of 178.54 will be > the west value longitude of 174.37 but also > the east value of -169.5849609375

Then it would return as false for a check to see if it is inside a bbox. It should be < the east value to pass the check.

If the west is a negative and the east is a positive, there is not a problem, only the inverse where west is positive and east is negative.

Describe the solution you'd like We should do a dateline check, like:

bbox =  [west,south,east,north]  # these should be int values, using names for example here
if west is a positive number and east is a negative value:
    new_east = east + 360
    bbox = [west,south,new_east,north]

Describe alternatives you've considered Considered generating a linestring geometry representing the dateline/antemeridian and checking if the bbox geometry intersects it, but this is a more expensive computation

Additional context The issue here over is that the dateline is where the +/-180 degrees of a sphere "resets" from positive to negative, which can break out bbox check

cbeddow commented 3 years ago

We could move this to be a good first issue

Rubix982 commented 3 years ago

Done!

Rubix982 commented 2 years ago

This was solved in #116