geobox 2.0.1__py3-none-any.whl → 2.2.0__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.
- geobox/__init__.py +61 -63
- geobox/aio/__init__.py +61 -63
- geobox/aio/api.py +489 -473
- geobox/aio/apikey.py +263 -263
- geobox/aio/attachment.py +341 -339
- geobox/aio/base.py +261 -262
- geobox/aio/basemap.py +196 -196
- geobox/aio/dashboard.py +340 -342
- geobox/aio/feature.py +23 -33
- geobox/aio/field.py +315 -321
- geobox/aio/file.py +72 -72
- geobox/aio/layout.py +340 -341
- geobox/aio/log.py +23 -23
- geobox/aio/map.py +1033 -1034
- geobox/aio/model3d.py +415 -415
- geobox/aio/mosaic.py +696 -696
- geobox/aio/plan.py +314 -314
- geobox/aio/query.py +693 -693
- geobox/aio/raster.py +907 -869
- geobox/aio/raster_analysis.py +740 -0
- geobox/aio/route.py +4 -4
- geobox/aio/scene.py +340 -342
- geobox/aio/settings.py +18 -18
- geobox/aio/task.py +404 -402
- geobox/aio/tile3d.py +337 -339
- geobox/aio/tileset.py +102 -103
- geobox/aio/usage.py +52 -51
- geobox/aio/user.py +506 -507
- geobox/aio/vector_tool.py +1968 -0
- geobox/aio/vectorlayer.py +315 -306
- geobox/aio/version.py +272 -273
- geobox/aio/view.py +1019 -983
- geobox/aio/workflow.py +340 -341
- geobox/api.py +18 -2
- geobox/apikey.py +262 -262
- geobox/attachment.py +336 -337
- geobox/base.py +384 -384
- geobox/basemap.py +194 -194
- geobox/dashboard.py +339 -341
- geobox/enums.py +432 -348
- geobox/feature.py +5 -5
- geobox/field.py +320 -320
- geobox/file.py +4 -4
- geobox/layout.py +339 -340
- geobox/log.py +4 -4
- geobox/map.py +1031 -1032
- geobox/model3d.py +410 -410
- geobox/mosaic.py +696 -696
- geobox/plan.py +313 -313
- geobox/query.py +691 -691
- geobox/raster.py +907 -863
- geobox/raster_analysis.py +737 -0
- geobox/scene.py +341 -342
- geobox/settings.py +194 -194
- geobox/task.py +399 -400
- geobox/tile3d.py +337 -338
- geobox/tileset.py +4 -4
- geobox/usage.py +3 -3
- geobox/user.py +503 -503
- geobox/vector_tool.py +1968 -0
- geobox/vectorlayer.py +5 -5
- geobox/version.py +272 -272
- geobox/view.py +981 -981
- geobox/workflow.py +338 -339
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/METADATA +15 -1
- geobox-2.2.0.dist-info/RECORD +72 -0
- geobox-2.0.1.dist-info/RECORD +0 -68
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/WHEEL +0 -0
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/top_level.txt +0 -0
geobox/aio/basemap.py
CHANGED
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
from typing import List, Dict, Optional, TYPE_CHECKING
|
|
2
|
-
from urllib.parse import urljoin, urlencode
|
|
3
|
-
|
|
4
|
-
from .base import AsyncBase
|
|
5
|
-
from ..exception import NotFoundError
|
|
6
|
-
from ..utils import clean_data
|
|
7
|
-
|
|
8
|
-
if TYPE_CHECKING:
|
|
9
|
-
from . import AsyncGeoboxClient
|
|
10
|
-
from ..api import GeoboxClient
|
|
11
|
-
from ..basemap import Basemap
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class
|
|
15
|
-
|
|
16
|
-
BASE_ENDPOINT = 'basemaps/'
|
|
17
|
-
|
|
18
|
-
def __init__(self,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"""
|
|
22
|
-
Initialize a basemap instance.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
26
|
-
data (Dict): The data of the basemap.
|
|
27
|
-
"""
|
|
28
|
-
super().__init__(api, data=data)
|
|
29
|
-
self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}/"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@classmethod
|
|
33
|
-
async def get_basemaps(cls, api: 'AsyncGeoboxClient') -> List['
|
|
34
|
-
"""
|
|
35
|
-
[async] Get a list of basemaps
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
39
|
-
|
|
40
|
-
Returns:
|
|
41
|
-
List[
|
|
42
|
-
|
|
43
|
-
Example:
|
|
44
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
45
|
-
>>> from geobox.aio.basemap import
|
|
46
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
47
|
-
>>> basemaps = await
|
|
48
|
-
or
|
|
49
|
-
>>> basemaps = await client.get_basemaps()
|
|
50
|
-
"""
|
|
51
|
-
response = await api.get(cls.BASE_ENDPOINT)
|
|
52
|
-
if not response:
|
|
53
|
-
return []
|
|
54
|
-
|
|
55
|
-
items = []
|
|
56
|
-
for item in response:
|
|
57
|
-
response[item]['name'] = item
|
|
58
|
-
items.append(response[item])
|
|
59
|
-
|
|
60
|
-
return [cls(api, item) for item in items]
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@classmethod
|
|
64
|
-
async def get_basemap(cls, api: 'AsyncGeoboxClient', name: str) -> '
|
|
65
|
-
"""
|
|
66
|
-
[async] Get a basemap object
|
|
67
|
-
|
|
68
|
-
Args:
|
|
69
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
70
|
-
name: the basemap name
|
|
71
|
-
|
|
72
|
-
Returns:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Raises:
|
|
76
|
-
NotFoundError: if the base,ap with the specified name not found
|
|
77
|
-
|
|
78
|
-
Example:
|
|
79
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
80
|
-
>>> from geobox.aio.basemap import Basemap
|
|
81
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
82
|
-
>>> basemap = await Basemap.get_basemap(client, name='test')
|
|
83
|
-
or
|
|
84
|
-
>>> basemap = await client.get_basemap(name='test')
|
|
85
|
-
"""
|
|
86
|
-
response = await cls.get_basemaps(api)
|
|
87
|
-
basemap = [basemap for basemap in response if basemap.name == name]
|
|
88
|
-
if not basemap:
|
|
89
|
-
raise NotFoundError(f'Basemap with name "{name}" not found.')
|
|
90
|
-
|
|
91
|
-
return basemap[0]
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
@property
|
|
95
|
-
def thumbnail(self) -> str:
|
|
96
|
-
"""
|
|
97
|
-
Get the thumbnail url of the basemap
|
|
98
|
-
|
|
99
|
-
Returns:
|
|
100
|
-
str: the thumbnail url
|
|
101
|
-
"""
|
|
102
|
-
return super().
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
@property
|
|
106
|
-
def wmts(self) -> str:
|
|
107
|
-
"""
|
|
108
|
-
Get the wmts url of the basemap
|
|
109
|
-
|
|
110
|
-
Returns:
|
|
111
|
-
str: the wmts url
|
|
112
|
-
"""
|
|
113
|
-
endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
|
|
114
|
-
|
|
115
|
-
if not self.api.access_token and self.api.apikey:
|
|
116
|
-
endpoint = f"{endpoint}?apikey={self.api.apikey}"
|
|
117
|
-
|
|
118
|
-
return endpoint
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
@property
|
|
122
|
-
async def server_url(self) -> str:
|
|
123
|
-
"""
|
|
124
|
-
[async] Get the server url of the basemap
|
|
125
|
-
|
|
126
|
-
Returns:
|
|
127
|
-
str: the server url
|
|
128
|
-
"""
|
|
129
|
-
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
|
|
130
|
-
return await self.api.get(endpoint)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
@property
|
|
134
|
-
async def proxy_url(self) -> str:
|
|
135
|
-
"""
|
|
136
|
-
[async] Get the proxy url of the basemap
|
|
137
|
-
|
|
138
|
-
Returns:
|
|
139
|
-
str: the proxy url
|
|
140
|
-
"""
|
|
141
|
-
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
|
|
142
|
-
return await self.api.get(endpoint)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
@classmethod
|
|
146
|
-
async def proxy_basemap(cls, api: 'response', url: str) -> None:
|
|
147
|
-
"""
|
|
148
|
-
[async] Proxy the basemap
|
|
149
|
-
|
|
150
|
-
Args:
|
|
151
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
152
|
-
url (str): the proxy server url.
|
|
153
|
-
|
|
154
|
-
Returns:
|
|
155
|
-
None
|
|
156
|
-
|
|
157
|
-
Example:
|
|
158
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
159
|
-
>>> from geobox.aio.basemap import Basemap
|
|
160
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
161
|
-
>>> await Basemap.proxy_basemap(client, url='proxy_server_url')
|
|
162
|
-
or
|
|
163
|
-
>>> await client.proxy_basemap(url='proxy_server_url')
|
|
164
|
-
"""
|
|
165
|
-
param = clean_data({
|
|
166
|
-
'url': url
|
|
167
|
-
})
|
|
168
|
-
query_string = urlencode(param)
|
|
169
|
-
endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
|
|
170
|
-
await api.get(endpoint)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
def to_sync(self, sync_client: '
|
|
174
|
-
"""
|
|
175
|
-
Switch to sync version of the basemap instance to have access to the sync methods
|
|
176
|
-
|
|
177
|
-
Args:
|
|
178
|
-
sync_client (
|
|
179
|
-
|
|
180
|
-
Returns:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
Example:
|
|
184
|
-
>>> from geobox import Geoboxclient
|
|
185
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
186
|
-
>>> from geobox.aio.basemap import
|
|
187
|
-
>>> client = GeoboxClient()
|
|
188
|
-
>>> async with AsyncGeoboxClient() as async_client:
|
|
189
|
-
>>> basemap = await
|
|
190
|
-
or
|
|
191
|
-
>>> basemap = await async_client.get_basemap(name='test')
|
|
192
|
-
>>> sync_basemap = basemap.to_sync(client)
|
|
193
|
-
"""
|
|
194
|
-
from ..basemap import Basemap
|
|
195
|
-
|
|
196
|
-
return
|
|
1
|
+
from typing import List, Dict, Optional, TYPE_CHECKING
|
|
2
|
+
from urllib.parse import urljoin, urlencode
|
|
3
|
+
|
|
4
|
+
from .base import AsyncBase
|
|
5
|
+
from ..exception import NotFoundError
|
|
6
|
+
from ..utils import clean_data
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from . import AsyncGeoboxClient
|
|
10
|
+
from ..api import GeoboxClient
|
|
11
|
+
from ..basemap import Basemap
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AsyncBasemap(AsyncBase):
|
|
15
|
+
|
|
16
|
+
BASE_ENDPOINT = 'basemaps/'
|
|
17
|
+
|
|
18
|
+
def __init__(self,
|
|
19
|
+
api: 'AsyncGeoboxClient',
|
|
20
|
+
data: Optional[Dict] = {}):
|
|
21
|
+
"""
|
|
22
|
+
Initialize a basemap instance.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
26
|
+
data (Dict): The data of the basemap.
|
|
27
|
+
"""
|
|
28
|
+
super().__init__(api, data=data)
|
|
29
|
+
self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}/"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@classmethod
|
|
33
|
+
async def get_basemaps(cls, api: 'AsyncGeoboxClient') -> List['AsyncBasemap']:
|
|
34
|
+
"""
|
|
35
|
+
[async] Get a list of basemaps
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
List[AsyncBaseMap]: list of basemaps.
|
|
42
|
+
|
|
43
|
+
Example:
|
|
44
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
45
|
+
>>> from geobox.aio.basemap import AsyncBasemap
|
|
46
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
47
|
+
>>> basemaps = await AsyncBasemap.get_basemaps(client)
|
|
48
|
+
or
|
|
49
|
+
>>> basemaps = await client.get_basemaps()
|
|
50
|
+
"""
|
|
51
|
+
response = await api.get(cls.BASE_ENDPOINT)
|
|
52
|
+
if not response:
|
|
53
|
+
return []
|
|
54
|
+
|
|
55
|
+
items = []
|
|
56
|
+
for item in response:
|
|
57
|
+
response[item]['name'] = item
|
|
58
|
+
items.append(response[item])
|
|
59
|
+
|
|
60
|
+
return [cls(api, item) for item in items]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
async def get_basemap(cls, api: 'AsyncGeoboxClient', name: str) -> 'AsyncBasemap':
|
|
65
|
+
"""
|
|
66
|
+
[async] Get a basemap object
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
70
|
+
name: the basemap name
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
AsyncBasemap: the basemap object
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
NotFoundError: if the base,ap with the specified name not found
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
80
|
+
>>> from geobox.aio.basemap import Basemap
|
|
81
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
82
|
+
>>> basemap = await Basemap.get_basemap(client, name='test')
|
|
83
|
+
or
|
|
84
|
+
>>> basemap = await client.get_basemap(name='test')
|
|
85
|
+
"""
|
|
86
|
+
response = await cls.get_basemaps(api)
|
|
87
|
+
basemap = [basemap for basemap in response if basemap.name == name]
|
|
88
|
+
if not basemap:
|
|
89
|
+
raise NotFoundError(f'Basemap with name "{name}" not found.')
|
|
90
|
+
|
|
91
|
+
return basemap[0]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def thumbnail(self) -> str:
|
|
96
|
+
"""
|
|
97
|
+
Get the thumbnail url of the basemap
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
str: the thumbnail url
|
|
101
|
+
"""
|
|
102
|
+
return super()._thumbnail()
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def wmts(self) -> str:
|
|
107
|
+
"""
|
|
108
|
+
Get the wmts url of the basemap
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
str: the wmts url
|
|
112
|
+
"""
|
|
113
|
+
endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
|
|
114
|
+
|
|
115
|
+
if not self.api.access_token and self.api.apikey:
|
|
116
|
+
endpoint = f"{endpoint}?apikey={self.api.apikey}"
|
|
117
|
+
|
|
118
|
+
return endpoint
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
async def server_url(self) -> str:
|
|
123
|
+
"""
|
|
124
|
+
[async] Get the server url of the basemap
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
str: the server url
|
|
128
|
+
"""
|
|
129
|
+
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
|
|
130
|
+
return await self.api.get(endpoint)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
async def proxy_url(self) -> str:
|
|
135
|
+
"""
|
|
136
|
+
[async] Get the proxy url of the basemap
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
str: the proxy url
|
|
140
|
+
"""
|
|
141
|
+
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
|
|
142
|
+
return await self.api.get(endpoint)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@classmethod
|
|
146
|
+
async def proxy_basemap(cls, api: 'response', url: str) -> None:
|
|
147
|
+
"""
|
|
148
|
+
[async] Proxy the basemap
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
152
|
+
url (str): the proxy server url.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
None
|
|
156
|
+
|
|
157
|
+
Example:
|
|
158
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
159
|
+
>>> from geobox.aio.basemap import Basemap
|
|
160
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
161
|
+
>>> await Basemap.proxy_basemap(client, url='proxy_server_url')
|
|
162
|
+
or
|
|
163
|
+
>>> await client.proxy_basemap(url='proxy_server_url')
|
|
164
|
+
"""
|
|
165
|
+
param = clean_data({
|
|
166
|
+
'url': url
|
|
167
|
+
})
|
|
168
|
+
query_string = urlencode(param)
|
|
169
|
+
endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
|
|
170
|
+
await api.get(endpoint)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def to_sync(self, sync_client: 'GeoboxClient') -> 'Basemap':
|
|
174
|
+
"""
|
|
175
|
+
Switch to sync version of the basemap instance to have access to the sync methods
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
Basemap: the sync instance of the basemap.
|
|
182
|
+
|
|
183
|
+
Example:
|
|
184
|
+
>>> from geobox import Geoboxclient
|
|
185
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
186
|
+
>>> from geobox.aio.basemap import AsyncBasemap
|
|
187
|
+
>>> client = GeoboxClient()
|
|
188
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
189
|
+
>>> basemap = await AsyncBasemap.get_basemap(async_client, name='test')
|
|
190
|
+
or
|
|
191
|
+
>>> basemap = await async_client.get_basemap(name='test')
|
|
192
|
+
>>> sync_basemap = basemap.to_sync(client)
|
|
193
|
+
"""
|
|
194
|
+
from ..basemap import Basemap
|
|
195
|
+
|
|
196
|
+
return Basemap(api=sync_client, data=self.data)
|