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] Check bounding box validity #40

Closed cbeddow closed 2 years ago

cbeddow commented 3 years ago

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

The user could pass bad values such as strange numbers or invalid values, or reverse the values like a latitude,longitude instead of longitude,latitude order

Describe the solution you'd like We should consider a validity check here. A bbox should always consist of a (lon,lat) for the lower left (i.e. southwest) corner of a box, and (lon,lat) for the upper right (northeast) corner.

  1. longitude range: has a min value of -180, a max value of 180
  2. latitude range: has a min value of -90, max value of 90
  3. latitude compare: in a bbox of [west,south,east,north] the value of south should always be smaller than the value of north (because south is lower, closer to -90, north is higher toward 90, even if both are negative)
  4. longitude compare: in a bbox of [west,south,east,north] the value of west should always be smaller than the value of east, EXCEPT if the bbox crosses the international dateline, which we can check with #39. Technically any time that west > east it could cross the dateline, but could also be an error. If it passes the dateline test we should just consider it valid.
  5. zero values: 0 is valid for all values in a bbox n a bbox of [west,south,east,north] the value
  6. equal values: we should never see east == west and never see south == north. This produces a flat box or line that has no inner size to get data within

Describe alternatives you've considered Alternative could be to let the user just get a message that the function fails and somewhere it will be due to an a invalid bounding box, but not made clear to the user

OmarMuhammedAli commented 3 years ago

@joeyouss is working on this issue!

Rubix982 commented 3 years ago

Welcome, @joeyouss!

Rubix982 commented 3 years ago

@joeyouss, if you need any help or if you run into any problems, let us know!

joeyouss commented 3 years ago

Thank you !