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