geobox 1.4.2__py3-none-any.whl → 2.0.1__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 +2 -2
- geobox/aio/__init__.py +63 -0
- geobox/aio/api.py +2640 -0
- geobox/aio/apikey.py +263 -0
- geobox/aio/attachment.py +339 -0
- geobox/aio/base.py +262 -0
- geobox/aio/basemap.py +196 -0
- geobox/aio/dashboard.py +342 -0
- geobox/aio/feature.py +527 -0
- geobox/aio/field.py +321 -0
- geobox/aio/file.py +522 -0
- geobox/aio/layout.py +341 -0
- geobox/aio/log.py +145 -0
- geobox/aio/map.py +1034 -0
- geobox/aio/model3d.py +415 -0
- geobox/aio/mosaic.py +696 -0
- geobox/aio/plan.py +315 -0
- geobox/aio/query.py +693 -0
- geobox/aio/raster.py +869 -0
- geobox/aio/route.py +63 -0
- geobox/aio/scene.py +342 -0
- geobox/aio/settings.py +194 -0
- geobox/aio/task.py +402 -0
- geobox/aio/tile3d.py +339 -0
- geobox/aio/tileset.py +672 -0
- geobox/aio/usage.py +243 -0
- geobox/aio/user.py +507 -0
- geobox/aio/vectorlayer.py +1363 -0
- geobox/aio/version.py +273 -0
- geobox/aio/view.py +983 -0
- geobox/aio/workflow.py +341 -0
- geobox/api.py +14 -15
- geobox/apikey.py +28 -1
- geobox/attachment.py +27 -1
- geobox/base.py +4 -4
- geobox/basemap.py +30 -1
- geobox/dashboard.py +27 -0
- geobox/feature.py +33 -13
- geobox/field.py +33 -21
- geobox/file.py +40 -46
- geobox/layout.py +28 -1
- geobox/log.py +31 -7
- geobox/map.py +34 -2
- geobox/model3d.py +31 -37
- geobox/mosaic.py +28 -7
- geobox/plan.py +29 -3
- geobox/query.py +39 -14
- geobox/raster.py +26 -13
- geobox/scene.py +26 -0
- geobox/settings.py +30 -1
- geobox/task.py +28 -6
- geobox/tile3d.py +27 -1
- geobox/tileset.py +26 -5
- geobox/usage.py +32 -1
- geobox/user.py +62 -6
- geobox/utils.py +34 -0
- geobox/vectorlayer.py +40 -4
- geobox/version.py +25 -1
- geobox/view.py +37 -17
- geobox/workflow.py +27 -1
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/METADATA +4 -1
- geobox-2.0.1.dist-info/RECORD +68 -0
- geobox-1.4.2.dist-info/RECORD +0 -38
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/WHEEL +0 -0
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/top_level.txt +0 -0
geobox/aio/mosaic.py
ADDED
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
from urllib.parse import urljoin, urlencode
|
|
2
|
+
from typing import Dict, List, Optional, Union, TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
from ..utils import clean_data
|
|
5
|
+
from .raster import Raster
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from . import AsyncGeoboxClient
|
|
9
|
+
from .user import User
|
|
10
|
+
from .task import Task
|
|
11
|
+
from ..api import GeoboxClient as SyncGeoboxClient
|
|
12
|
+
from ..mosaic import Mosaic as SyncMosaic
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Mosaic(Raster):
|
|
16
|
+
|
|
17
|
+
BASE_ENDPOINT: str = 'mosaics/'
|
|
18
|
+
|
|
19
|
+
def __init__(self,
|
|
20
|
+
api: 'AsyncGeoboxClient',
|
|
21
|
+
uuid: str,
|
|
22
|
+
data: Optional[Dict] = {}):
|
|
23
|
+
"""
|
|
24
|
+
Initialize a Mosaic instance.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
28
|
+
uuid (str): The unique identifier for the mosaic.
|
|
29
|
+
data (Dict, optional): The data of the mosaic.
|
|
30
|
+
"""
|
|
31
|
+
super().__init__(api, uuid, data)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
async def get_mosaics(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['Mosaic'], int]:
|
|
36
|
+
"""
|
|
37
|
+
[async] Get a list of mosaics.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
41
|
+
|
|
42
|
+
Keyword Args:
|
|
43
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'".
|
|
44
|
+
seacrh (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
45
|
+
search_fields (str): comma separated list of fields for searching.
|
|
46
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
47
|
+
return_count (bool): if true, the number of mosaics will be returned.
|
|
48
|
+
skip (int): number of mosaics to skip. minimum value is 0.
|
|
49
|
+
limit (int): maximum number of mosaics to return. minimum value is 1.
|
|
50
|
+
user_id (int): specific user. privileges required.
|
|
51
|
+
shared (bool): Whether to return shared mosaics. default is False.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
List['Mosaic'] | int: A list of Mosaic instances or the number of mosaics.
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
58
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
59
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
60
|
+
>>> mosaics = await Mosaic.get_mosaics(client, q="name LIKE '%GIS%'")
|
|
61
|
+
or
|
|
62
|
+
>>> mosaics = await client.get_mosaics(q="name LIKE '%GIS%'")
|
|
63
|
+
"""
|
|
64
|
+
params = {
|
|
65
|
+
'terrain': kwargs.get('terrain', None),
|
|
66
|
+
'f': 'json',
|
|
67
|
+
'q': kwargs.get('q', None),
|
|
68
|
+
'search': kwargs.get('search', None),
|
|
69
|
+
'search_fields': kwargs.get('search_fields', None),
|
|
70
|
+
'order_by': kwargs.get('order_by', None),
|
|
71
|
+
'return_count': kwargs.get('return_count', False),
|
|
72
|
+
'skip': kwargs.get('skip', 0),
|
|
73
|
+
'limit': kwargs.get('limit', 100),
|
|
74
|
+
'user_id': kwargs.get('user_id', None),
|
|
75
|
+
'shared': kwargs.get('shared', False)
|
|
76
|
+
}
|
|
77
|
+
return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: Mosaic(api, item['uuid'], item))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
async def get_mosaics_by_ids(cls, api: 'AsyncGeoboxClient', ids: List[str], user_id: int = None) -> List['Mosaic']:
|
|
82
|
+
"""
|
|
83
|
+
[async] Get mosaics by their IDs.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
87
|
+
ids (List[str]): The IDs of the mosaics.
|
|
88
|
+
user_id (int, optional): specific user. privileges required.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
List[Mosaic]: A list of Mosaic instances.
|
|
92
|
+
|
|
93
|
+
Example:
|
|
94
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
95
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
96
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
97
|
+
>>> mosaics = await Mosaic.get_mosaics_by_ids(client, ids=['1, 2, 3'])
|
|
98
|
+
or
|
|
99
|
+
>>> mosaics = await client.get_mosaics_by_ids(ids=['1, 2, 3'])
|
|
100
|
+
"""
|
|
101
|
+
params = {
|
|
102
|
+
'ids': ids,
|
|
103
|
+
'user_id': user_id
|
|
104
|
+
}
|
|
105
|
+
endpoint = urljoin(cls.BASE_ENDPOINT, 'get-mosaics/')
|
|
106
|
+
return await super()._get_list_by_ids(api, endpoint, params, factory_func=lambda api, item: Mosaic(api, item['uuid'], item))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
async def create_mosaic(cls,
|
|
111
|
+
api: 'AsyncGeoboxClient',
|
|
112
|
+
name:str,
|
|
113
|
+
display_name: str = None,
|
|
114
|
+
description: str = None,
|
|
115
|
+
pixel_selection: str = None,
|
|
116
|
+
min_zoom: int = None,
|
|
117
|
+
user_id: int = None) -> 'Mosaic':
|
|
118
|
+
"""
|
|
119
|
+
[async] Create New Raster Mosaic
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
123
|
+
name (str): The name of the mosaic.
|
|
124
|
+
display_name (str, optional): The display name of the mosaic.
|
|
125
|
+
description (str, optional): The description of the mosaic.
|
|
126
|
+
pixel_selection (str, optional): The pixel selection of the mosaic.
|
|
127
|
+
min_zoom (int, optional): The minimum zoom of the mosaic.
|
|
128
|
+
user_id (int, optional): specific user. privileges required.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Mosaic: The created mosaic.
|
|
132
|
+
|
|
133
|
+
Example:
|
|
134
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
135
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
136
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
137
|
+
>>> mosaic = await Mosaic.create_mosaic(client, name='mosaic_name')
|
|
138
|
+
or
|
|
139
|
+
>>> mosaic = await client.create_mosaic(name='mosaic_name')
|
|
140
|
+
"""
|
|
141
|
+
data = {
|
|
142
|
+
'name': name,
|
|
143
|
+
'display_name': display_name,
|
|
144
|
+
'description': description,
|
|
145
|
+
'pixel_selection': pixel_selection,
|
|
146
|
+
'min_zoom': min_zoom,
|
|
147
|
+
'user_id': user_id
|
|
148
|
+
}
|
|
149
|
+
return await super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: Mosaic(api, item['uuid'], item))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@classmethod
|
|
153
|
+
async def get_mosaic(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'Mosaic':
|
|
154
|
+
"""
|
|
155
|
+
[async] Get a mosaic by uuid.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
159
|
+
uuid (str): The UUID of the mosaic.
|
|
160
|
+
user_id (int, optional): specific user. privileges required.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
Mosaic: The mosaic object.
|
|
164
|
+
|
|
165
|
+
Example:
|
|
166
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
167
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
168
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
169
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
170
|
+
or
|
|
171
|
+
>>> mosaic = await client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
|
|
172
|
+
"""
|
|
173
|
+
params = {
|
|
174
|
+
'f': 'json',
|
|
175
|
+
'user_id': user_id
|
|
176
|
+
}
|
|
177
|
+
return await super()._get_detail(api, cls.BASE_ENDPOINT, uuid, params, factory_func=lambda api, item: Mosaic(api, item['uuid'], item))
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@classmethod
|
|
181
|
+
async def get_mosaic_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['Mosaic', None]:
|
|
182
|
+
"""
|
|
183
|
+
[async] Get a mosaic by name
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
187
|
+
name (str): the name of the mosaic to get
|
|
188
|
+
user_id (int, optional): specific user. privileges required.
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
Mosaic | None: returns the mosaic if a mosaic matches the given name, else None
|
|
192
|
+
|
|
193
|
+
Example:
|
|
194
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
195
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
196
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
197
|
+
>>> mosaic = await Mosaic.get_mosaic_by_name(client, name='test')
|
|
198
|
+
or
|
|
199
|
+
>>> mosaic = await client.get_mosaic_by_name(name='test')
|
|
200
|
+
"""
|
|
201
|
+
mosaics = await cls.get_mosaics(api, q=f"name = '{name}'", user_id=user_id)
|
|
202
|
+
if mosaics and mosaics[0].name == name:
|
|
203
|
+
return mosaics[0]
|
|
204
|
+
else:
|
|
205
|
+
return None
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
async def update(self, **kwargs) -> Dict:
|
|
209
|
+
"""
|
|
210
|
+
[async] Update a mosaic.
|
|
211
|
+
|
|
212
|
+
Keyword Args:
|
|
213
|
+
name (str): The name of the mosaic.
|
|
214
|
+
display_name (str): The display name of the mosaic.
|
|
215
|
+
description (str): The description of the mosaic.
|
|
216
|
+
pixel_selection (str): The pixel selection of the mosaic.
|
|
217
|
+
min_zoom (int): The minimum zoom of the mosaic.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
Dict: the updated data
|
|
221
|
+
|
|
222
|
+
Example:
|
|
223
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
224
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
225
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
226
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
227
|
+
>>> await mosaic.update(name='new_name', display_name='new_display_name', description='new_description', pixel_selection='new_pixel_selection', min_zoom=10)
|
|
228
|
+
"""
|
|
229
|
+
data = {
|
|
230
|
+
'name': kwargs.get('name'),
|
|
231
|
+
'display_name': kwargs.get('display_name'),
|
|
232
|
+
'description': kwargs.get('description'),
|
|
233
|
+
'pixel_selection': kwargs.get('pixel_selection'),
|
|
234
|
+
'min_zoom': kwargs.get('min_zoom')
|
|
235
|
+
}
|
|
236
|
+
return await super()._update(self.endpoint, data)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
async def delete(self) -> None:
|
|
240
|
+
"""
|
|
241
|
+
[async] Delete the mosaic.
|
|
242
|
+
|
|
243
|
+
Returns:
|
|
244
|
+
None
|
|
245
|
+
|
|
246
|
+
Example:
|
|
247
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
248
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
249
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
250
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
251
|
+
>>> await mosaic.delete()
|
|
252
|
+
"""
|
|
253
|
+
await super().delete()
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@property
|
|
257
|
+
def thumbnail(self) -> str:
|
|
258
|
+
"""
|
|
259
|
+
Get the thumbnail of the mosaic.
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
str: The thumbnail url of the mosaic.
|
|
263
|
+
|
|
264
|
+
Example:
|
|
265
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
266
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
267
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
268
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
269
|
+
>>> mosaic.thumbnail
|
|
270
|
+
"""
|
|
271
|
+
return super().thumbnail
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
async def get_point(self, lat: float, lng: float) -> List[float]:
|
|
275
|
+
"""
|
|
276
|
+
[async] Get the points of the mosaic.
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
lat (float): The latitude of the point.
|
|
280
|
+
lng (float): The longitude of the point.
|
|
281
|
+
|
|
282
|
+
Returns:
|
|
283
|
+
List[float]: The points of the mosaic.
|
|
284
|
+
|
|
285
|
+
Example:
|
|
286
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
287
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
288
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
289
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
290
|
+
>>> await mosaic.get_point(lat=60, lng=50)
|
|
291
|
+
"""
|
|
292
|
+
return await super().get_point(lat, lng)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def get_render_png_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}', **kwargs) -> str:
|
|
296
|
+
"""
|
|
297
|
+
Get the tile render URL of the mosaic.
|
|
298
|
+
|
|
299
|
+
Args:
|
|
300
|
+
x (int, optional): The x coordinate of the tile.
|
|
301
|
+
y (int, optional): The y coordinate of the tile.
|
|
302
|
+
z (int, optional): The zoom level of the tile.
|
|
303
|
+
|
|
304
|
+
Keyword Args:
|
|
305
|
+
indexes (str, optional): list of comma separated band indexes to be rendered. e.g. 1, 2, 3
|
|
306
|
+
nodata (int, optional)
|
|
307
|
+
expression (str, optional): band math expression. e.g. b1*b2+b3
|
|
308
|
+
rescale (List, optional): comma (',') separated Min,Max range. Can set multiple time for multiple bands.
|
|
309
|
+
color_formula (str, optional): Color formula. e.g. gamma R 0.5
|
|
310
|
+
colormap_name (str, optional)
|
|
311
|
+
colormap (str, optional): JSON encoded custom Colormap. e.g. {"0": "#ff0000", "1": "#00ff00"} or [[[0, 100], "#ff0000"], [[100, 200], "#00ff00"]]
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
str: The tile render URL of the mosaic.
|
|
315
|
+
|
|
316
|
+
Example:
|
|
317
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
318
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
319
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
320
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
321
|
+
>>> mosaic.get_tile_render_url(x=1, y=1, z=1)
|
|
322
|
+
"""
|
|
323
|
+
return super().get_render_png_url(x, y, z, **kwargs)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def get_tile_png_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}') -> str:
|
|
327
|
+
"""
|
|
328
|
+
Get the tile PNG URL of the mosaic.
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
x (int, optional): The x coordinate of the tile.
|
|
332
|
+
y (int, optional): The y coordinate of the tile.
|
|
333
|
+
z (int, optional): The zoom level of the tile.
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
str: The tile PNG URL of the mosaic.
|
|
337
|
+
|
|
338
|
+
Example:
|
|
339
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
340
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
341
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
342
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
343
|
+
>>> mosaic.get_tile_png_url(x=1, y=1, z=1)
|
|
344
|
+
"""
|
|
345
|
+
return super().get_tile_png_url(x, y, z)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
async def get_tile_json(self) -> str:
|
|
349
|
+
"""
|
|
350
|
+
[async] Get the tile JSON of the raster.
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
str: The tile JSON of the raster.
|
|
354
|
+
|
|
355
|
+
Example:
|
|
356
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
357
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
358
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
359
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
360
|
+
>>> await mosaic.get_tile_json()
|
|
361
|
+
"""
|
|
362
|
+
return await super().get_tile_json()
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def wmts(self, scale: int = None) -> str:
|
|
366
|
+
"""
|
|
367
|
+
Get the WMTS URL
|
|
368
|
+
|
|
369
|
+
Args:
|
|
370
|
+
scale (int, optional): The scale of the raster. values are: 1, 2
|
|
371
|
+
|
|
372
|
+
Returns:
|
|
373
|
+
str: The WMTS URL of the mosaic.
|
|
374
|
+
|
|
375
|
+
Example:
|
|
376
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
377
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
378
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
379
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
380
|
+
>>> mosaic.wmts(scale=1)
|
|
381
|
+
"""
|
|
382
|
+
return super().wmts(scale)
|
|
383
|
+
|
|
384
|
+
@property
|
|
385
|
+
async def settings(self) -> Dict:
|
|
386
|
+
"""
|
|
387
|
+
[async] Get the settings of the mosaic.
|
|
388
|
+
|
|
389
|
+
Returns:
|
|
390
|
+
Dict: The settings of the mosaic.
|
|
391
|
+
|
|
392
|
+
Example:
|
|
393
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
394
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
395
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
396
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
397
|
+
>>> await mosaic.settings
|
|
398
|
+
"""
|
|
399
|
+
return await super().settings
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
async def update_settings(self, settings: Dict) -> Dict:
|
|
403
|
+
"""
|
|
404
|
+
[async] Update the settings
|
|
405
|
+
|
|
406
|
+
settings (Dict): settings dictionary
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
Dict: updated settings
|
|
410
|
+
|
|
411
|
+
Example:
|
|
412
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
413
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
414
|
+
>>> mosaic1 = await client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
|
|
415
|
+
>>> mosaic2 = await client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
|
|
416
|
+
>>> await mosaic1.update_settings(mosaic2.settings)
|
|
417
|
+
"""
|
|
418
|
+
return await super().update_settings(settings)
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
async def set_settings(self, **kwargs) -> None:
|
|
422
|
+
"""
|
|
423
|
+
[async] Set the settings of the mosaic.
|
|
424
|
+
|
|
425
|
+
Keyword Args:
|
|
426
|
+
nodata (int): The nodata value of the raster.
|
|
427
|
+
indexes (list[int]): The indexes of the raster.
|
|
428
|
+
rescale (list[int]): The rescale of the raster.
|
|
429
|
+
colormap_name (str): The colormap name of the raster.
|
|
430
|
+
color_formula (str): The color formula of the raster.
|
|
431
|
+
expression (str): The expression of the raster.
|
|
432
|
+
exaggeraion (int): The exaggeraion of the raster.
|
|
433
|
+
min_zoom (int): The min zoom of the raster.
|
|
434
|
+
max_zoom (int): The max zoom of the raster.
|
|
435
|
+
use_cache (bool): Whether to use cache of the raster.
|
|
436
|
+
cache_until_zoom (int): The cache until zoom of the raster.
|
|
437
|
+
|
|
438
|
+
Returns:
|
|
439
|
+
None
|
|
440
|
+
|
|
441
|
+
Example:
|
|
442
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
443
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
444
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
445
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
446
|
+
>>> await mosaic.set_settings(nodata=0,
|
|
447
|
+
... indexes=[1],
|
|
448
|
+
... rescale=[[0, 10000]],
|
|
449
|
+
... colormap_name='gist_rainbow',
|
|
450
|
+
... color_formula='Gamma R 0.5',
|
|
451
|
+
... expression='b1 * 2',
|
|
452
|
+
... exaggeraion=10,
|
|
453
|
+
... min_zoom=0,
|
|
454
|
+
... max_zoom=22,
|
|
455
|
+
... use_cache=True,
|
|
456
|
+
... cache_until_zoom=17)
|
|
457
|
+
"""
|
|
458
|
+
return await super().set_settings(**kwargs)
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
async def get_rasters(self, user_id: int = None) -> List[Raster]:
|
|
462
|
+
"""
|
|
463
|
+
[async] Get the rasters of the mosaic
|
|
464
|
+
|
|
465
|
+
Args:
|
|
466
|
+
user_id (int, optional): specific user. privileges required.
|
|
467
|
+
|
|
468
|
+
Returns:
|
|
469
|
+
List[Raster]: The rasters of the mosaic.
|
|
470
|
+
|
|
471
|
+
Example:
|
|
472
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
473
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
474
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
475
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
476
|
+
>>> rasters = await mosaic.get_rasters()
|
|
477
|
+
"""
|
|
478
|
+
params = clean_data({
|
|
479
|
+
'user_id': user_id
|
|
480
|
+
})
|
|
481
|
+
query_string = urlencode(params)
|
|
482
|
+
endpoint = urljoin(self.BASE_ENDPOINT, f'{self.uuid}/rasters?{query_string}')
|
|
483
|
+
response = await self.api.get(endpoint)
|
|
484
|
+
return [Raster(self.api, raster_data['uuid'], raster_data) for raster_data in response]
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
async def add_rasters(self, rasters: List['Raster']) -> None:
|
|
488
|
+
"""
|
|
489
|
+
[async] Add a raster to the mosaic.
|
|
490
|
+
|
|
491
|
+
Args:
|
|
492
|
+
rasters (List[Raster]): list of raster objects to add
|
|
493
|
+
|
|
494
|
+
Returns:
|
|
495
|
+
None
|
|
496
|
+
|
|
497
|
+
Example:
|
|
498
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
499
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
500
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
501
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
502
|
+
>>> rasters = await client.get_rasters()
|
|
503
|
+
>>> await mosaic.add_raster(rasters=rasters)
|
|
504
|
+
"""
|
|
505
|
+
data = clean_data({
|
|
506
|
+
'raster_ids': [raster.id for raster in rasters]
|
|
507
|
+
})
|
|
508
|
+
endpoint = urljoin(self.BASE_ENDPOINT, f'{self.uuid}/rasters/')
|
|
509
|
+
await self.api.post(endpoint, data, is_json=False)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
async def remove_rasters(self, rasters: List['Raster']) -> None:
|
|
513
|
+
"""
|
|
514
|
+
[async] Remove a raster from the mosaic.
|
|
515
|
+
|
|
516
|
+
Args:
|
|
517
|
+
rasters (List[Raster]): list of raster objects to remove
|
|
518
|
+
|
|
519
|
+
Returns:
|
|
520
|
+
None
|
|
521
|
+
|
|
522
|
+
Example:
|
|
523
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
524
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
525
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
526
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
527
|
+
>>> rasters = await client.get_raster()
|
|
528
|
+
>>> await mosaic.remove_rasters(rasters=rasters)
|
|
529
|
+
"""
|
|
530
|
+
param = clean_data({
|
|
531
|
+
'raster_ids': [raster.id for raster in rasters]
|
|
532
|
+
})
|
|
533
|
+
query_string = urlencode(param)
|
|
534
|
+
endpoint = urljoin(self.BASE_ENDPOINT, f'{self.uuid}/rasters/?{query_string}')
|
|
535
|
+
await self.api.delete(endpoint, is_json=False)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
async def share(self, users: List['User']) -> None:
|
|
539
|
+
"""
|
|
540
|
+
[async] Shares the mosaic with specified users.
|
|
541
|
+
|
|
542
|
+
Args:
|
|
543
|
+
users (List[User]): The list of user objects to share the mosaic with.
|
|
544
|
+
|
|
545
|
+
Returns:
|
|
546
|
+
None
|
|
547
|
+
|
|
548
|
+
Example:
|
|
549
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
550
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
551
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
552
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
553
|
+
>>> users = await client.search_users(search='John')
|
|
554
|
+
>>> await mosaic.share(users=users)
|
|
555
|
+
"""
|
|
556
|
+
await super()._share(self.endpoint, users)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
async def unshare(self, users: List['User']) -> None:
|
|
560
|
+
"""
|
|
561
|
+
[async] Unshares the mosaic with specified users.
|
|
562
|
+
|
|
563
|
+
Args:
|
|
564
|
+
users (List[User]): The list of user objects to unshare the mosaic with.
|
|
565
|
+
|
|
566
|
+
Returns:
|
|
567
|
+
None
|
|
568
|
+
|
|
569
|
+
Example:
|
|
570
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
571
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
572
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
573
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
574
|
+
>>> users = await client.search_users(search='John')
|
|
575
|
+
>>> await mosaic.unshare(users=users)
|
|
576
|
+
"""
|
|
577
|
+
await super()._unshare(self.endpoint, users)
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
|
|
581
|
+
"""
|
|
582
|
+
[async] Retrieves the list of users the file is shared with.
|
|
583
|
+
|
|
584
|
+
Args:
|
|
585
|
+
search (str, optional): The search query.
|
|
586
|
+
skip (int, optional): The number of users to skip.
|
|
587
|
+
limit (int, optional): The maximum number of users to retrieve.
|
|
588
|
+
|
|
589
|
+
Returns:
|
|
590
|
+
List[User]: The list of shared users.
|
|
591
|
+
|
|
592
|
+
Example:
|
|
593
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
594
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
595
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
596
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
597
|
+
>>> await mosaic.get_shared_users(search='John', skip=0, limit=10)
|
|
598
|
+
"""
|
|
599
|
+
params = {
|
|
600
|
+
'search': search,
|
|
601
|
+
'skip': skip,
|
|
602
|
+
'limit': limit
|
|
603
|
+
}
|
|
604
|
+
return await super()._get_shared_users(self.endpoint, params)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
async def seed_cache(self,
|
|
608
|
+
from_zoom: int = None,
|
|
609
|
+
to_zoom: int = None,
|
|
610
|
+
extent: List[int] = None,
|
|
611
|
+
workers: int = 1) -> List['Task']:
|
|
612
|
+
"""
|
|
613
|
+
[async] Seed the cache of the mosaic.
|
|
614
|
+
|
|
615
|
+
Args:
|
|
616
|
+
from_zoom (int, optional): The from zoom of the mosaic.
|
|
617
|
+
to_zoom (int, optional): The to zoom of the mosaic.
|
|
618
|
+
extent (list[int], optional): The extent of the mosaic.
|
|
619
|
+
workers (int, optional): The number of workers to use. default is 1.
|
|
620
|
+
|
|
621
|
+
Returns:
|
|
622
|
+
List[Task]: The task of the seed cache.
|
|
623
|
+
|
|
624
|
+
Example:
|
|
625
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
626
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
627
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
628
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
629
|
+
>>> task = await mosaic.seed_cache(from_zoom=0, to_zoom=22, extent=[0, 0, 100, 100], workers=1)
|
|
630
|
+
"""
|
|
631
|
+
data = {
|
|
632
|
+
'from_zoom': from_zoom,
|
|
633
|
+
'to_zoom': to_zoom,
|
|
634
|
+
'extent': extent,
|
|
635
|
+
'workers': workers
|
|
636
|
+
}
|
|
637
|
+
return await super()._seed_cache(endpoint=self.endpoint, data=data)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
async def clear_cache(self) -> None:
|
|
641
|
+
"""
|
|
642
|
+
[async] Clear the cache of the mosaic.
|
|
643
|
+
|
|
644
|
+
Returns:
|
|
645
|
+
None
|
|
646
|
+
|
|
647
|
+
Example:
|
|
648
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
649
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
650
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
651
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
652
|
+
>>> await mosaic.clear_cache()
|
|
653
|
+
"""
|
|
654
|
+
return await super().clear_cache()
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
@property
|
|
658
|
+
async def cache_size(self) -> int:
|
|
659
|
+
"""
|
|
660
|
+
[async] Get the size of the cache of the mosaic.
|
|
661
|
+
|
|
662
|
+
Returns:
|
|
663
|
+
int: The size of the cache of the mosaic.
|
|
664
|
+
|
|
665
|
+
Example:
|
|
666
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
667
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
668
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
669
|
+
>>> mosaic = await Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
670
|
+
>>> await mosaic.cache_size
|
|
671
|
+
"""
|
|
672
|
+
return await super().cache_size
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncMosaic':
|
|
676
|
+
"""
|
|
677
|
+
Switch to sync version of the mosaic instance to have access to the sync methods
|
|
678
|
+
|
|
679
|
+
Args:
|
|
680
|
+
sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
681
|
+
|
|
682
|
+
Returns:
|
|
683
|
+
geobox.mosaic.Mosiac: the sync instance of the mosaic.
|
|
684
|
+
|
|
685
|
+
Example:
|
|
686
|
+
>>> from geobox import Geoboxclient
|
|
687
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
688
|
+
>>> from geobox.aio.mosaic import Mosaic
|
|
689
|
+
>>> client = GeoboxClient()
|
|
690
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
691
|
+
>>> mosaic = await Mosaic.get_mosaic(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
692
|
+
>>> sync_mosaic = mosaic.to_sync(client)
|
|
693
|
+
"""
|
|
694
|
+
from ..mosaic import Mosaic as SyncMosaic
|
|
695
|
+
|
|
696
|
+
return SyncMosaic(api=sync_client, uuid=self.uuid, data=self.data)
|