pygeobox 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygeobox/__init__.py +63 -63
- pygeobox/api.py +2517 -2517
- pygeobox/apikey.py +232 -232
- pygeobox/attachment.py +297 -297
- pygeobox/base.py +364 -364
- pygeobox/basemap.py +162 -162
- pygeobox/dashboard.py +316 -316
- pygeobox/enums.py +354 -354
- pygeobox/exception.py +47 -47
- pygeobox/field.py +309 -309
- pygeobox/map.py +858 -858
- pygeobox/model3d.py +334 -334
- pygeobox/mosaic.py +647 -647
- pygeobox/plan.py +260 -260
- pygeobox/query.py +668 -668
- pygeobox/raster.py +756 -756
- pygeobox/route.py +63 -63
- pygeobox/scene.py +317 -317
- pygeobox/settings.py +165 -165
- pygeobox/task.py +354 -354
- pygeobox/tile3d.py +294 -294
- pygeobox/tileset.py +585 -585
- pygeobox/user.py +423 -423
- pygeobox/utils.py +43 -43
- pygeobox/vectorlayer.py +1149 -1149
- pygeobox/version.py +248 -248
- pygeobox/view.py +859 -859
- pygeobox/workflow.py +315 -315
- {pygeobox-1.0.1.dist-info → pygeobox-1.0.3.dist-info}/METADATA +18 -33
- pygeobox-1.0.3.dist-info/RECORD +37 -0
- {pygeobox-1.0.1.dist-info → pygeobox-1.0.3.dist-info}/licenses/LICENSE +21 -21
- pygeobox-1.0.1.dist-info/RECORD +0 -37
- {pygeobox-1.0.1.dist-info → pygeobox-1.0.3.dist-info}/WHEEL +0 -0
- {pygeobox-1.0.1.dist-info → pygeobox-1.0.3.dist-info}/top_level.txt +0 -0
pygeobox/basemap.py
CHANGED
@@ -1,163 +1,163 @@
|
|
1
|
-
from typing import List, Dict, Optional, TYPE_CHECKING
|
2
|
-
from urllib.parse import urljoin, urlencode
|
3
|
-
|
4
|
-
from .base import Base
|
5
|
-
from .exception import NotFoundError
|
6
|
-
from .utils import clean_data
|
7
|
-
|
8
|
-
if TYPE_CHECKING:
|
9
|
-
from . import GeoboxClient
|
10
|
-
|
11
|
-
class Basemap(Base):
|
12
|
-
|
13
|
-
BASE_ENDPOINT = 'basemaps/'
|
14
|
-
|
15
|
-
def __init__(self,
|
16
|
-
api: 'GeoboxClient',
|
17
|
-
data: Optional[Dict] = {}):
|
18
|
-
"""
|
19
|
-
Initialize a basemap instance.
|
20
|
-
|
21
|
-
Args:
|
22
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
23
|
-
data (Dict): The data of the basemap.
|
24
|
-
"""
|
25
|
-
super().__init__(api, data=data)
|
26
|
-
self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}"
|
27
|
-
|
28
|
-
|
29
|
-
@classmethod
|
30
|
-
def get_basemaps(cls, api: 'GeoboxClient') -> List['Basemap']:
|
31
|
-
"""
|
32
|
-
Get a list of basemaps
|
33
|
-
|
34
|
-
Args:
|
35
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
36
|
-
|
37
|
-
Returns:
|
38
|
-
List[BaseMap]: list of basemaps.
|
39
|
-
|
40
|
-
Example:
|
41
|
-
>>> from geobox import GeoboxClient
|
42
|
-
>>> from geobox.basemap import Basemap
|
43
|
-
>>> client = GeoboxClient()
|
44
|
-
>>> basemaps = Basemap.get_basemaps(client)
|
45
|
-
or
|
46
|
-
>>> basemaps = client.get_basemaps()
|
47
|
-
"""
|
48
|
-
response = api.get(cls.BASE_ENDPOINT)
|
49
|
-
if not response:
|
50
|
-
return []
|
51
|
-
|
52
|
-
items = []
|
53
|
-
for item in response:
|
54
|
-
response[item]['name'] = item
|
55
|
-
items.append(response[item])
|
56
|
-
|
57
|
-
return [cls(api, item) for item in items]
|
58
|
-
|
59
|
-
|
60
|
-
@classmethod
|
61
|
-
def get_basemap(cls, api: 'GeoboxClient', name: str) -> 'Basemap':
|
62
|
-
"""
|
63
|
-
Get a basemap object
|
64
|
-
|
65
|
-
Args:
|
66
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
67
|
-
name: the basemap name
|
68
|
-
|
69
|
-
Returns:
|
70
|
-
Basemap: the basemap object
|
71
|
-
|
72
|
-
Raises:
|
73
|
-
NotFoundError: if the base,ap with the specified name not found
|
74
|
-
|
75
|
-
Example:
|
76
|
-
>>> from geobox import GeoboxClient
|
77
|
-
>>> from geobox.basemap import Basemap
|
78
|
-
>>> client = GeoboxClient()
|
79
|
-
>>> basemap = Basemap.get_basemap(client, name='test')
|
80
|
-
or
|
81
|
-
>>> basemap = client.get_basemap(name='test')
|
82
|
-
"""
|
83
|
-
basemap = [basemap for basemap in cls.get_basemaps(api) if basemap.name == name]
|
84
|
-
if not basemap:
|
85
|
-
raise NotFoundError(f'Basemap with name "{name}" not found.')
|
86
|
-
|
87
|
-
return basemap[0]
|
88
|
-
|
89
|
-
|
90
|
-
@property
|
91
|
-
def thumbnail(self) -> str:
|
92
|
-
"""
|
93
|
-
Get the thumbnail url of the basemap
|
94
|
-
|
95
|
-
Returns:
|
96
|
-
str: the thumbnail url
|
97
|
-
"""
|
98
|
-
endpoint = f"{self.api.base_url}{self.endpoint}/thumbnail.png"
|
99
|
-
return endpoint
|
100
|
-
|
101
|
-
|
102
|
-
@property
|
103
|
-
def wmts(self) -> str:
|
104
|
-
"""
|
105
|
-
Get the wmts url of the basemap
|
106
|
-
|
107
|
-
Returns:
|
108
|
-
str: the wmts url
|
109
|
-
"""
|
110
|
-
endpoint = f"{self.api.base_url}{self.endpoint}/wmts"
|
111
|
-
return endpoint
|
112
|
-
|
113
|
-
|
114
|
-
@property
|
115
|
-
def server_url(self) -> str:
|
116
|
-
"""
|
117
|
-
Get the server url of the basemap
|
118
|
-
|
119
|
-
Returns:
|
120
|
-
str: the server url
|
121
|
-
"""
|
122
|
-
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
|
123
|
-
return self.api.get(endpoint)
|
124
|
-
|
125
|
-
|
126
|
-
@property
|
127
|
-
def proxy_url(self) -> str:
|
128
|
-
"""
|
129
|
-
Get the proxy url of the basemap
|
130
|
-
|
131
|
-
Returns:
|
132
|
-
str: the proxy url
|
133
|
-
"""
|
134
|
-
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
|
135
|
-
return self.api.get(endpoint)
|
136
|
-
|
137
|
-
|
138
|
-
@classmethod
|
139
|
-
def proxy_basemap(cls, api: 'GeoboxClient', url: str) -> None:
|
140
|
-
"""
|
141
|
-
Proxy the basemap
|
142
|
-
|
143
|
-
Args:
|
144
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
145
|
-
url (str): the proxy server url.
|
146
|
-
|
147
|
-
Returns:
|
148
|
-
None
|
149
|
-
|
150
|
-
Example:
|
151
|
-
>>> from geobox import GeoboxClient
|
152
|
-
>>> from geobox.basemap import Basemap
|
153
|
-
>>> client = GeoboxClient()
|
154
|
-
>>> Basemap.proxy_basemap(client, url='proxy_server_url')
|
155
|
-
or
|
156
|
-
>>> client.proxy_basemap(url='proxy_server_url')
|
157
|
-
"""
|
158
|
-
param = clean_data({
|
159
|
-
'url': url
|
160
|
-
})
|
161
|
-
query_string = urlencode(param)
|
162
|
-
endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
|
1
|
+
from typing import List, Dict, Optional, TYPE_CHECKING
|
2
|
+
from urllib.parse import urljoin, urlencode
|
3
|
+
|
4
|
+
from .base import Base
|
5
|
+
from .exception import NotFoundError
|
6
|
+
from .utils import clean_data
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from . import GeoboxClient
|
10
|
+
|
11
|
+
class Basemap(Base):
|
12
|
+
|
13
|
+
BASE_ENDPOINT = 'basemaps/'
|
14
|
+
|
15
|
+
def __init__(self,
|
16
|
+
api: 'GeoboxClient',
|
17
|
+
data: Optional[Dict] = {}):
|
18
|
+
"""
|
19
|
+
Initialize a basemap instance.
|
20
|
+
|
21
|
+
Args:
|
22
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
23
|
+
data (Dict): The data of the basemap.
|
24
|
+
"""
|
25
|
+
super().__init__(api, data=data)
|
26
|
+
self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}"
|
27
|
+
|
28
|
+
|
29
|
+
@classmethod
|
30
|
+
def get_basemaps(cls, api: 'GeoboxClient') -> List['Basemap']:
|
31
|
+
"""
|
32
|
+
Get a list of basemaps
|
33
|
+
|
34
|
+
Args:
|
35
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
36
|
+
|
37
|
+
Returns:
|
38
|
+
List[BaseMap]: list of basemaps.
|
39
|
+
|
40
|
+
Example:
|
41
|
+
>>> from geobox import GeoboxClient
|
42
|
+
>>> from geobox.basemap import Basemap
|
43
|
+
>>> client = GeoboxClient()
|
44
|
+
>>> basemaps = Basemap.get_basemaps(client)
|
45
|
+
or
|
46
|
+
>>> basemaps = client.get_basemaps()
|
47
|
+
"""
|
48
|
+
response = api.get(cls.BASE_ENDPOINT)
|
49
|
+
if not response:
|
50
|
+
return []
|
51
|
+
|
52
|
+
items = []
|
53
|
+
for item in response:
|
54
|
+
response[item]['name'] = item
|
55
|
+
items.append(response[item])
|
56
|
+
|
57
|
+
return [cls(api, item) for item in items]
|
58
|
+
|
59
|
+
|
60
|
+
@classmethod
|
61
|
+
def get_basemap(cls, api: 'GeoboxClient', name: str) -> 'Basemap':
|
62
|
+
"""
|
63
|
+
Get a basemap object
|
64
|
+
|
65
|
+
Args:
|
66
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
67
|
+
name: the basemap name
|
68
|
+
|
69
|
+
Returns:
|
70
|
+
Basemap: the basemap object
|
71
|
+
|
72
|
+
Raises:
|
73
|
+
NotFoundError: if the base,ap with the specified name not found
|
74
|
+
|
75
|
+
Example:
|
76
|
+
>>> from geobox import GeoboxClient
|
77
|
+
>>> from geobox.basemap import Basemap
|
78
|
+
>>> client = GeoboxClient()
|
79
|
+
>>> basemap = Basemap.get_basemap(client, name='test')
|
80
|
+
or
|
81
|
+
>>> basemap = client.get_basemap(name='test')
|
82
|
+
"""
|
83
|
+
basemap = [basemap for basemap in cls.get_basemaps(api) if basemap.name == name]
|
84
|
+
if not basemap:
|
85
|
+
raise NotFoundError(f'Basemap with name "{name}" not found.')
|
86
|
+
|
87
|
+
return basemap[0]
|
88
|
+
|
89
|
+
|
90
|
+
@property
|
91
|
+
def thumbnail(self) -> str:
|
92
|
+
"""
|
93
|
+
Get the thumbnail url of the basemap
|
94
|
+
|
95
|
+
Returns:
|
96
|
+
str: the thumbnail url
|
97
|
+
"""
|
98
|
+
endpoint = f"{self.api.base_url}{self.endpoint}/thumbnail.png"
|
99
|
+
return endpoint
|
100
|
+
|
101
|
+
|
102
|
+
@property
|
103
|
+
def wmts(self) -> str:
|
104
|
+
"""
|
105
|
+
Get the wmts url of the basemap
|
106
|
+
|
107
|
+
Returns:
|
108
|
+
str: the wmts url
|
109
|
+
"""
|
110
|
+
endpoint = f"{self.api.base_url}{self.endpoint}/wmts"
|
111
|
+
return endpoint
|
112
|
+
|
113
|
+
|
114
|
+
@property
|
115
|
+
def server_url(self) -> str:
|
116
|
+
"""
|
117
|
+
Get the server url of the basemap
|
118
|
+
|
119
|
+
Returns:
|
120
|
+
str: the server url
|
121
|
+
"""
|
122
|
+
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
|
123
|
+
return self.api.get(endpoint)
|
124
|
+
|
125
|
+
|
126
|
+
@property
|
127
|
+
def proxy_url(self) -> str:
|
128
|
+
"""
|
129
|
+
Get the proxy url of the basemap
|
130
|
+
|
131
|
+
Returns:
|
132
|
+
str: the proxy url
|
133
|
+
"""
|
134
|
+
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
|
135
|
+
return self.api.get(endpoint)
|
136
|
+
|
137
|
+
|
138
|
+
@classmethod
|
139
|
+
def proxy_basemap(cls, api: 'GeoboxClient', url: str) -> None:
|
140
|
+
"""
|
141
|
+
Proxy the basemap
|
142
|
+
|
143
|
+
Args:
|
144
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
145
|
+
url (str): the proxy server url.
|
146
|
+
|
147
|
+
Returns:
|
148
|
+
None
|
149
|
+
|
150
|
+
Example:
|
151
|
+
>>> from geobox import GeoboxClient
|
152
|
+
>>> from geobox.basemap import Basemap
|
153
|
+
>>> client = GeoboxClient()
|
154
|
+
>>> Basemap.proxy_basemap(client, url='proxy_server_url')
|
155
|
+
or
|
156
|
+
>>> client.proxy_basemap(url='proxy_server_url')
|
157
|
+
"""
|
158
|
+
param = clean_data({
|
159
|
+
'url': url
|
160
|
+
})
|
161
|
+
query_string = urlencode(param)
|
162
|
+
endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
|
163
163
|
api.get(endpoint)
|