|
16 | 16 | """ |
17 | 17 |
|
18 | 18 | # Local Imports |
19 | | -from mapillary.models.exceptions import InvalidKwargError, InvalidOptionError |
| 19 | +from mapillary.models.exceptions import InvalidBBoxError, InvalidKwargError, InvalidOptionError |
20 | 20 | from mapillary.config.api.entities import Entities |
21 | 21 | from mapillary.models.client import Client |
22 | 22 |
|
23 | 23 | # Package Imports |
24 | 24 | import requests |
25 | 25 | import re |
26 | 26 |
|
| 27 | +def international_dateline_check(bbox): |
| 28 | + if bbox['west']>0 and bbox['east']<0: |
| 29 | + return True |
| 30 | + return False |
| 31 | + |
| 32 | +def bbox_validity_check(bbox): |
| 33 | + # longitude check |
| 34 | + if bbox['west'] < 180 or bbox['east'] > 180: |
| 35 | + raise InvalidBBoxError(message="Input values exceed their permitted limits") |
| 36 | + # lattitude check |
| 37 | + elif bbox['north'] > 90 or bbox['south'] < 90: |
| 38 | + raise InvalidBBoxError(message="Input values exceed their permitted limits") |
| 39 | + # longitude validity check |
| 40 | + elif bbox['west']>bbox['east'] : |
| 41 | + # extra check for international dateline |
| 42 | + # it could either be an error or cross an internaitonal dateline |
| 43 | + # hence if it is passing the dateline, return True |
| 44 | + if international_dateline_check(bbox): |
| 45 | + new_east = bbox['east'] + 360 |
| 46 | + bbox['east'] = new_east |
| 47 | + return bbox |
| 48 | + raise InvalidBBoxError(message="Invalid values") |
| 49 | + # lattitude validitiy check |
| 50 | + elif bbox['north']<bbox['south']: |
| 51 | + raise InvalidBBoxError(message="Invalid values") |
| 52 | + elif bbox['north']==bbox['south'] and bbox['west']==bbox['east']: |
| 53 | + # checking for equal values to avoid flat box |
| 54 | + raise InvalidBBoxError(message="Invalid values") |
27 | 55 |
|
| 56 | + return True |
| 57 | + |
28 | 58 | def kwarg_check(kwargs: dict, options: list, callback: str) -> bool: |
29 | 59 | """ |
30 | 60 | Checks for keyword arguments amongst the kwarg argument to fall into the options list |
|
0 commit comments