geobox 2.1.0__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 +491 -574
- 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 +88 -454
- geobox/aio/{analysis.py → raster_analysis.py} +153 -170
- 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 +316 -414
- geobox/aio/version.py +272 -273
- geobox/aio/view.py +1019 -983
- geobox/aio/workflow.py +340 -341
- geobox/api.py +14 -98
- 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 +31 -1
- 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 +5 -368
- geobox/{analysis.py → raster_analysis.py} +108 -128
- 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 -110
- geobox/version.py +272 -272
- geobox/view.py +981 -981
- geobox/workflow.py +338 -339
- {geobox-2.1.0.dist-info → geobox-2.2.0.dist-info}/METADATA +15 -1
- geobox-2.2.0.dist-info/RECORD +72 -0
- geobox-2.1.0.dist-info/RECORD +0 -70
- {geobox-2.1.0.dist-info → geobox-2.2.0.dist-info}/WHEEL +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.0.dist-info}/top_level.txt +0 -0
geobox/aio/vectorlayer.py
CHANGED
|
@@ -2,25 +2,25 @@ from urllib.parse import urljoin
|
|
|
2
2
|
from typing import List, Optional, TYPE_CHECKING, Dict, Union
|
|
3
3
|
|
|
4
4
|
from .base import AsyncBase
|
|
5
|
-
from .field import
|
|
6
|
-
from .feature import
|
|
7
|
-
from .task import
|
|
8
|
-
from .version import
|
|
5
|
+
from .field import AsyncField, FieldType
|
|
6
|
+
from .feature import AsyncFeature
|
|
7
|
+
from .task import AsyncTask
|
|
8
|
+
from .version import AsyncVectorLayerVersion
|
|
9
9
|
from ..utils import clean_data
|
|
10
10
|
from ..exception import NotFoundError
|
|
11
|
-
from ..enums import LayerType, InputGeomType, FileOutputFormat
|
|
11
|
+
from ..enums import LayerType, InputGeomType, FileOutputFormat
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
from .api import AsyncGeoboxClient
|
|
15
|
-
from .view import
|
|
16
|
-
from .user import
|
|
17
|
-
from .file import
|
|
18
|
-
from .attachment import
|
|
19
|
-
from ..api import GeoboxClient
|
|
20
|
-
from ..vectorlayer import VectorLayer
|
|
15
|
+
from .view import AsyncVectorLayerView
|
|
16
|
+
from .user import AsyncUser
|
|
17
|
+
from .file import AsyncFile
|
|
18
|
+
from .attachment import AsyncAttachment
|
|
19
|
+
from ..api import GeoboxClient
|
|
20
|
+
from ..vectorlayer import VectorLayer
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
class
|
|
23
|
+
class AsyncVectorLayer(AsyncBase):
|
|
24
24
|
"""
|
|
25
25
|
A class representing a vector layer in Geobox.
|
|
26
26
|
|
|
@@ -31,10 +31,10 @@ class VectorLayer(AsyncBase):
|
|
|
31
31
|
BASE_ENDPOINT = 'vectorLayers/'
|
|
32
32
|
|
|
33
33
|
def __init__(self,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
api: 'AsyncGeoboxClient',
|
|
35
|
+
uuid: str,
|
|
36
|
+
layer_type: LayerType,
|
|
37
|
+
data: Optional[Dict] = {}):
|
|
38
38
|
"""
|
|
39
39
|
Initialize a VectorLayer instance.
|
|
40
40
|
|
|
@@ -50,16 +50,16 @@ class VectorLayer(AsyncBase):
|
|
|
50
50
|
|
|
51
51
|
def __repr__(self) -> str:
|
|
52
52
|
"""
|
|
53
|
-
Return a string representation of the
|
|
53
|
+
Return a string representation of the AsyncVectorLayer object.
|
|
54
54
|
|
|
55
55
|
Returns:
|
|
56
|
-
str: A string representation of the
|
|
56
|
+
str: A string representation of the AsyncVectorLayer object.
|
|
57
57
|
"""
|
|
58
|
-
return f"
|
|
58
|
+
return f"AsyncVectorLayer(uuid={self.uuid}, name={self.name}, layer_type={self.layer_type})"
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
@classmethod
|
|
62
|
-
async def get_vectors(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['
|
|
62
|
+
async def get_vectors(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['AsyncVectorLayer'], int]:
|
|
63
63
|
"""
|
|
64
64
|
[async] Get a list of vector layers with optional filtering and pagination.
|
|
65
65
|
|
|
@@ -80,30 +80,30 @@ class VectorLayer(AsyncBase):
|
|
|
80
80
|
shared (bool): Whether to return shared layers. default is False.
|
|
81
81
|
|
|
82
82
|
Returns:
|
|
83
|
-
List[
|
|
83
|
+
List[AsyncVectorLayer] | int: A list of AsyncVectorLayer instances or the layers count if return_count is True.
|
|
84
84
|
|
|
85
85
|
Example:
|
|
86
86
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
87
|
-
>>> from geobox.aio.vectorlayer import
|
|
87
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
88
88
|
>>> async with AsyncGeoboxClient() as client:
|
|
89
|
-
>>> layers = await
|
|
90
|
-
...
|
|
91
|
-
...
|
|
92
|
-
...
|
|
93
|
-
...
|
|
94
|
-
...
|
|
95
|
-
...
|
|
96
|
-
...
|
|
97
|
-
...
|
|
89
|
+
>>> layers = await AsyncVectorLayer.get_vectors(api=client,
|
|
90
|
+
... include_settings=True,
|
|
91
|
+
... skip=0,
|
|
92
|
+
... limit=100,
|
|
93
|
+
... return_count=False,
|
|
94
|
+
... search="my_layer",
|
|
95
|
+
... search_fields="name, description",
|
|
96
|
+
... order_by="name",
|
|
97
|
+
... shared=True)
|
|
98
98
|
or
|
|
99
99
|
>>> layers = await client.get_vectors(include_settings=True,
|
|
100
|
-
...
|
|
101
|
-
...
|
|
102
|
-
...
|
|
103
|
-
...
|
|
104
|
-
...
|
|
105
|
-
...
|
|
106
|
-
...
|
|
100
|
+
... skip=0,
|
|
101
|
+
... limit=100,
|
|
102
|
+
... return_count=False,
|
|
103
|
+
... search="my_layer",
|
|
104
|
+
... search_fields="name, description",
|
|
105
|
+
... order_by="name",
|
|
106
|
+
... shared=True)
|
|
107
107
|
"""
|
|
108
108
|
params = {
|
|
109
109
|
'f': 'json',
|
|
@@ -122,11 +122,11 @@ class VectorLayer(AsyncBase):
|
|
|
122
122
|
return await super()._get_list(api=api,
|
|
123
123
|
endpoint=cls.BASE_ENDPOINT,
|
|
124
124
|
params=params,
|
|
125
|
-
factory_func=lambda api, item:
|
|
125
|
+
factory_func=lambda api, item: AsyncVectorLayer(api, item['uuid'], LayerType(item['layer_type']), item))
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
@classmethod
|
|
129
|
-
async def get_vector(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> '
|
|
129
|
+
async def get_vector(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'AsyncVectorLayer':
|
|
130
130
|
"""
|
|
131
131
|
[async] Get a specific vector layer by its UUID.
|
|
132
132
|
|
|
@@ -136,16 +136,16 @@ class VectorLayer(AsyncBase):
|
|
|
136
136
|
user_id (int, optional): Specific user. privileges required.
|
|
137
137
|
|
|
138
138
|
Returns:
|
|
139
|
-
|
|
139
|
+
AsyncVectorLayer: The requested layer instance.
|
|
140
140
|
|
|
141
141
|
Raises:
|
|
142
142
|
NotFoundError: If the layer with the specified UUID is not found.
|
|
143
143
|
|
|
144
144
|
Example:
|
|
145
145
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
146
|
-
>>> from geobox.aio.vectorlayer import
|
|
146
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
147
147
|
>>> async with AsyncGeoboxClient() as client:
|
|
148
|
-
>>> layer = await
|
|
148
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
149
149
|
or
|
|
150
150
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
151
151
|
"""
|
|
@@ -154,14 +154,14 @@ class VectorLayer(AsyncBase):
|
|
|
154
154
|
'user_id': user_id
|
|
155
155
|
}
|
|
156
156
|
return await super()._get_detail(api=api,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
endpoint=cls.BASE_ENDPOINT,
|
|
158
|
+
uuid=uuid,
|
|
159
|
+
params=params,
|
|
160
|
+
factory_func=lambda api, item: AsyncVectorLayer(api, item['uuid'], LayerType(item['layer_type']), item))
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
@classmethod
|
|
164
|
-
async def get_vector_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['
|
|
164
|
+
async def get_vector_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['AsyncVectorLayer', None]:
|
|
165
165
|
"""
|
|
166
166
|
[async] Get a vector layer by name
|
|
167
167
|
|
|
@@ -171,13 +171,13 @@ class VectorLayer(AsyncBase):
|
|
|
171
171
|
user_id (int, optional): specific user. privileges required.
|
|
172
172
|
|
|
173
173
|
Returns:
|
|
174
|
-
|
|
174
|
+
AsyncVectorLayer | None: returns the vector if a vector matches the given name, else None
|
|
175
175
|
|
|
176
176
|
Example:
|
|
177
177
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
178
|
-
>>> from geobox.aio.vectorlayer import
|
|
178
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
179
179
|
>>> async with AsyncGeoboxClient() as client:
|
|
180
|
-
>>> layer = await
|
|
180
|
+
>>> layer = await AsyncVectorLayer.get_vector_by_name(client, name='test')
|
|
181
181
|
or
|
|
182
182
|
>>> layer = await client.get_vector_by_name(name='test')
|
|
183
183
|
"""
|
|
@@ -189,7 +189,7 @@ class VectorLayer(AsyncBase):
|
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
@classmethod
|
|
192
|
-
async def get_vectors_by_ids(cls, api: 'AsyncGeoboxClient', ids: List[int], user_id: int = None, include_settings: bool = False) -> List['
|
|
192
|
+
async def get_vectors_by_ids(cls, api: 'AsyncGeoboxClient', ids: List[int], user_id: int = None, include_settings: bool = False) -> List['AsyncVectorLayer']:
|
|
193
193
|
"""
|
|
194
194
|
[async] Get vector layers by their IDs.
|
|
195
195
|
|
|
@@ -200,13 +200,13 @@ class VectorLayer(AsyncBase):
|
|
|
200
200
|
include_settings (bool, optional): Whether to include the layer settings. default is False.
|
|
201
201
|
|
|
202
202
|
Returns:
|
|
203
|
-
List[
|
|
203
|
+
List[AsyncVectorLayer]: The list of AsyncVectorLayer instances.
|
|
204
204
|
|
|
205
205
|
Example:
|
|
206
206
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
207
|
-
>>> from geobox.aio.vectorlayer import
|
|
207
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
208
208
|
>>> async with AsyncGeoboxClient() as client:
|
|
209
|
-
>>> layers = await
|
|
209
|
+
>>> layers = await AsyncVectorLayer.get_vectors_by_ids(api=client, ids=[1, 2, 3])
|
|
210
210
|
or
|
|
211
211
|
>>> layers = await client.get_vectors_by_ids(ids=[1, 2, 3])
|
|
212
212
|
"""
|
|
@@ -216,21 +216,21 @@ class VectorLayer(AsyncBase):
|
|
|
216
216
|
'include_settings': include_settings
|
|
217
217
|
}
|
|
218
218
|
return await super()._get_list_by_ids(api=api,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
endpoint=f'{cls.BASE_ENDPOINT}get-layers/',
|
|
220
|
+
params=params,
|
|
221
|
+
factory_func=lambda api, item: AsyncVectorLayer(api, item['uuid'], LayerType(item['layer_type']), item))
|
|
222
222
|
|
|
223
223
|
|
|
224
224
|
@classmethod
|
|
225
225
|
async def create_vector(cls,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
226
|
+
api: 'AsyncGeoboxClient',
|
|
227
|
+
name: str,
|
|
228
|
+
layer_type: LayerType,
|
|
229
|
+
display_name: str = None,
|
|
230
|
+
description: str = None,
|
|
231
|
+
has_z: bool = False,
|
|
232
|
+
temporary: bool = False,
|
|
233
|
+
fields: List = None) -> 'AsyncVectorLayer':
|
|
234
234
|
"""
|
|
235
235
|
[async] Create a new vector layer.
|
|
236
236
|
|
|
@@ -245,31 +245,31 @@ class VectorLayer(AsyncBase):
|
|
|
245
245
|
fields (List, optional): List of field definitions for the layer. default is None.
|
|
246
246
|
|
|
247
247
|
Returns:
|
|
248
|
-
|
|
248
|
+
AsyncVectorLayer: The newly created layer instance.
|
|
249
249
|
|
|
250
250
|
Raises:
|
|
251
251
|
ValidationError: If the layer data is invalid.
|
|
252
252
|
|
|
253
253
|
Example:
|
|
254
254
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
255
|
-
>>> from geobox.aio.vectorlayer import
|
|
255
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
256
256
|
>>> async with AsyncGeoboxClient() as client:
|
|
257
|
-
>>> layer = await
|
|
258
|
-
...
|
|
259
|
-
...
|
|
260
|
-
...
|
|
261
|
-
...
|
|
262
|
-
...
|
|
263
|
-
...
|
|
264
|
-
...
|
|
257
|
+
>>> layer = await AsyncVectorLayer.create_vector(api=client,
|
|
258
|
+
... name="my_layer",
|
|
259
|
+
... layer_type=LayerType.Point,
|
|
260
|
+
... display_name="My Layer",
|
|
261
|
+
... description="This is a description of my layer",
|
|
262
|
+
... has_z=False,
|
|
263
|
+
... temporary=True,
|
|
264
|
+
... fields=[{"name": "my_field", "datatype": "FieldTypeString"}])
|
|
265
265
|
or
|
|
266
266
|
>>> layer = await client.create_vector(name="my_layer",
|
|
267
|
-
...
|
|
268
|
-
...
|
|
269
|
-
...
|
|
270
|
-
...
|
|
271
|
-
...
|
|
272
|
-
...
|
|
267
|
+
... layer_type=LayerType.Point,
|
|
268
|
+
... display_name="My Layer",
|
|
269
|
+
... description="This is a description of my layer",
|
|
270
|
+
... has_z=False,
|
|
271
|
+
... temporary=True,
|
|
272
|
+
... fields=[{"name": "my_field", "datatype": "FieldTypeString"}])
|
|
273
273
|
"""
|
|
274
274
|
data = {
|
|
275
275
|
"name": name,
|
|
@@ -281,9 +281,9 @@ class VectorLayer(AsyncBase):
|
|
|
281
281
|
"fields": fields
|
|
282
282
|
}
|
|
283
283
|
return await super()._create(api=api,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
endpoint=cls.BASE_ENDPOINT,
|
|
285
|
+
data=data,
|
|
286
|
+
factory_func=lambda api, item: AsyncVectorLayer(api, item['uuid'], layer_type, item))
|
|
287
287
|
|
|
288
288
|
|
|
289
289
|
async def update(self, **kwargs) -> Dict:
|
|
@@ -303,9 +303,9 @@ class VectorLayer(AsyncBase):
|
|
|
303
303
|
|
|
304
304
|
Example:
|
|
305
305
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
306
|
-
>>> from geobox.aio.vectorlayer import
|
|
306
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
307
307
|
>>> async with AsyncGeoboxClient() as client:
|
|
308
|
-
>>> layer = await
|
|
308
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
309
309
|
>>> await layer.update(name="new_name")
|
|
310
310
|
>>> await layer.update(display_name="new_display_name")
|
|
311
311
|
>>> await layer.update(description="new_description")
|
|
@@ -327,12 +327,12 @@ class VectorLayer(AsyncBase):
|
|
|
327
327
|
|
|
328
328
|
Example:
|
|
329
329
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
330
|
-
>>> from geobox.aio.vectorlayer import
|
|
330
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
331
331
|
>>> async with AsyncGeoboxClient() as client:
|
|
332
|
-
>>> layer = await
|
|
332
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
333
333
|
>>> await layer.delete()
|
|
334
334
|
"""
|
|
335
|
-
await super().
|
|
335
|
+
await super()._delete(endpoint=self.endpoint)
|
|
336
336
|
|
|
337
337
|
|
|
338
338
|
async def make_permanent(self) -> None:
|
|
@@ -344,9 +344,9 @@ class VectorLayer(AsyncBase):
|
|
|
344
344
|
|
|
345
345
|
Example:
|
|
346
346
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
347
|
-
>>> from geobox.aio.vectorlayer import
|
|
347
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
348
348
|
>>> async with AsyncGeoboxClient() as client:
|
|
349
|
-
>>> layer = await
|
|
349
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
350
350
|
>>> await layer.make_permanent()
|
|
351
351
|
"""
|
|
352
352
|
endpoint = urljoin(self.endpoint, 'makePermanent/')
|
|
@@ -354,49 +354,49 @@ class VectorLayer(AsyncBase):
|
|
|
354
354
|
self._update_properties(response)
|
|
355
355
|
|
|
356
356
|
|
|
357
|
-
async def share(self, users: List['
|
|
357
|
+
async def share(self, users: List['AsyncUser']) -> None:
|
|
358
358
|
"""
|
|
359
359
|
[async] Shares the layer with specified users.
|
|
360
360
|
|
|
361
361
|
Args:
|
|
362
|
-
users (List[
|
|
362
|
+
users (List[AsyncUser]): The list of user objects to share the layer with.
|
|
363
363
|
|
|
364
364
|
Returns:
|
|
365
365
|
None
|
|
366
366
|
|
|
367
367
|
Example:
|
|
368
368
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
369
|
-
>>> from geobox.aio.vectorlayer import
|
|
369
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
370
370
|
>>> async with AsyncGeoboxClient() as client:
|
|
371
|
-
>>> layer = await
|
|
371
|
+
>>> layer = await AsyncVectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
372
372
|
>>> users = await client.search_users(search="John")
|
|
373
373
|
>>> await layer.share(users=users)
|
|
374
374
|
"""
|
|
375
375
|
await super()._share(self.endpoint, users)
|
|
376
376
|
|
|
377
377
|
|
|
378
|
-
async def unshare(self, users: List['
|
|
378
|
+
async def unshare(self, users: List['AsyncUser']) -> None:
|
|
379
379
|
"""
|
|
380
380
|
[async] Unshares the layer with specified users.
|
|
381
381
|
|
|
382
382
|
Args:
|
|
383
|
-
users (List[
|
|
383
|
+
users (List[AsyncUser]): The list of user objectss to unshare the layer with.
|
|
384
384
|
|
|
385
385
|
Returns:
|
|
386
386
|
None
|
|
387
387
|
|
|
388
388
|
Example:
|
|
389
389
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
390
|
-
>>> from geobox.aio.vectorlayer import
|
|
390
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
391
391
|
>>> async with AsyncGeoboxClient() as client:
|
|
392
|
-
>>> layer = await
|
|
392
|
+
>>> layer = await AsyncVectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
393
393
|
>>> users = await client.search_users(search="John")
|
|
394
394
|
>>> await layer.unshare(users=users)
|
|
395
395
|
"""
|
|
396
396
|
await super()._unshare(self.endpoint, users)
|
|
397
397
|
|
|
398
398
|
|
|
399
|
-
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['
|
|
399
|
+
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['AsyncUser']:
|
|
400
400
|
"""
|
|
401
401
|
[async] Retrieves the list of users the layer is shared with.
|
|
402
402
|
|
|
@@ -406,13 +406,13 @@ class VectorLayer(AsyncBase):
|
|
|
406
406
|
limit (int, optional): The maximum number of users to retrieve.
|
|
407
407
|
|
|
408
408
|
Returns:
|
|
409
|
-
List[
|
|
409
|
+
List[AsyncUser]: The list of shared users.
|
|
410
410
|
|
|
411
411
|
Example:
|
|
412
412
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
413
|
-
>>> from geobox.aio.vectorlayer import
|
|
413
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
414
414
|
>>> async with AsyncGeoboxClient() as client:
|
|
415
|
-
>>> layer = await
|
|
415
|
+
>>> layer = await AsyncVectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
416
416
|
>>> await layer.get_shared_users(search='John', skip=0, limit=10)
|
|
417
417
|
"""
|
|
418
418
|
params = {
|
|
@@ -423,7 +423,7 @@ class VectorLayer(AsyncBase):
|
|
|
423
423
|
return await super()._get_shared_users(self.endpoint, params)
|
|
424
424
|
|
|
425
425
|
|
|
426
|
-
async def create_version(self, name: str, display_name: str = None, description: str = None) -> '
|
|
426
|
+
async def create_version(self, name: str, display_name: str = None, description: str = None) -> 'AsyncVectorLayerVersion':
|
|
427
427
|
"""
|
|
428
428
|
[async] Create a version from the layer
|
|
429
429
|
|
|
@@ -437,7 +437,7 @@ class VectorLayer(AsyncBase):
|
|
|
437
437
|
|
|
438
438
|
Example:
|
|
439
439
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
440
|
-
>>> from geobox.aio.vectorlayer import
|
|
440
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
441
441
|
>>> async with AsyncGeoboxClient() as client:
|
|
442
442
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
443
443
|
>>> version = await layer.create_version(name="my_version")
|
|
@@ -448,10 +448,10 @@ class VectorLayer(AsyncBase):
|
|
|
448
448
|
"description": description
|
|
449
449
|
}
|
|
450
450
|
endpoint = urljoin(self.endpoint, 'versions')
|
|
451
|
-
return await super()._create(self.api, endpoint, data, factory_func=lambda api, item:
|
|
451
|
+
return await super()._create(self.api, endpoint, data, factory_func=lambda api, item: AsyncVectorLayerVersion(api, item['uuid'], item))
|
|
452
452
|
|
|
453
453
|
|
|
454
|
-
async def get_versions(self, **kwargs) -> List['
|
|
454
|
+
async def get_versions(self, **kwargs) -> List['AsyncVectorLayerVersion']:
|
|
455
455
|
"""
|
|
456
456
|
[async] Get list of versions of the current vector layer object with optional filtering and pagination.
|
|
457
457
|
|
|
@@ -467,18 +467,17 @@ class VectorLayer(AsyncBase):
|
|
|
467
467
|
shared (bool): Whether to return shared versions. default is False.
|
|
468
468
|
|
|
469
469
|
Returns:
|
|
470
|
-
List[
|
|
470
|
+
List[AsyncVectorLayerVersion] | int: A list of vector layer version instances or the total number of versions.
|
|
471
471
|
|
|
472
472
|
Example:
|
|
473
473
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
474
|
-
>>> from geobox.aio.vectorlayer import VectorLayer
|
|
475
474
|
>>> async with AsyncGeoboxClient() as client:
|
|
476
475
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
477
476
|
>>> versions = await layer.get_versions()
|
|
478
477
|
or
|
|
479
478
|
>>> versions = await layer.get_versions()
|
|
480
479
|
"""
|
|
481
|
-
return await
|
|
480
|
+
return await AsyncVectorLayerVersion.get_versions(self.api, layer_id=self.id, **kwargs)
|
|
482
481
|
|
|
483
482
|
|
|
484
483
|
@property
|
|
@@ -491,9 +490,9 @@ class VectorLayer(AsyncBase):
|
|
|
491
490
|
|
|
492
491
|
Example:
|
|
493
492
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
494
|
-
>>> from geobox.aio.vectorlayer import
|
|
493
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
495
494
|
>>> async with AsyncGeoboxClient() as client:
|
|
496
|
-
>>> layer = await
|
|
495
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
497
496
|
>>> layer.wfs
|
|
498
497
|
"""
|
|
499
498
|
if self.api.access_token:
|
|
@@ -502,27 +501,27 @@ class VectorLayer(AsyncBase):
|
|
|
502
501
|
return f'{self.api.base_url}{self.endpoint}apikey:{self.api.apikey}/wfs/'
|
|
503
502
|
|
|
504
503
|
|
|
505
|
-
async def get_fields(self) -> List['
|
|
504
|
+
async def get_fields(self) -> List['AsyncField']:
|
|
506
505
|
"""
|
|
507
506
|
[async] Get all fields in the layer.
|
|
508
507
|
|
|
509
508
|
Returns:
|
|
510
|
-
List[
|
|
509
|
+
List[AsyncField]: A list of Field instances representing the layer's fields.
|
|
511
510
|
|
|
512
511
|
Example:
|
|
513
512
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
514
|
-
>>> from geobox.aio.vectorlayer import
|
|
513
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
515
514
|
>>> async with AsyncGeoboxClient() as client:
|
|
516
|
-
>>> layer = await
|
|
515
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
517
516
|
>>> fields = await layer.get_fields()
|
|
518
517
|
"""
|
|
519
518
|
endpoint = urljoin(self.endpoint, 'fields/')
|
|
520
519
|
return await super()._get_list(api=self.api,
|
|
521
|
-
|
|
522
|
-
|
|
520
|
+
endpoint=endpoint,
|
|
521
|
+
factory_func=lambda api, item: AsyncField(layer=self, data_type=FieldType(item['datatype']), field_id=item['id'], data=item))
|
|
523
522
|
|
|
524
523
|
|
|
525
|
-
async def get_field(self, field_id: int) -> '
|
|
524
|
+
async def get_field(self, field_id: int) -> 'AsyncField':
|
|
526
525
|
"""
|
|
527
526
|
[async] Get a specific field by its ID.
|
|
528
527
|
|
|
@@ -537,9 +536,9 @@ class VectorLayer(AsyncBase):
|
|
|
537
536
|
|
|
538
537
|
Example:
|
|
539
538
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
540
|
-
>>> from geobox.aio.vectorlayer import
|
|
539
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
541
540
|
>>> async with AsyncGeoboxClient() as client:
|
|
542
|
-
>>> layer = await
|
|
541
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
543
542
|
>>> field = await layer.get_field(field_id=1)
|
|
544
543
|
"""
|
|
545
544
|
field = next((f for f in await self.get_fields() if f.id == field_id), None)
|
|
@@ -549,7 +548,7 @@ class VectorLayer(AsyncBase):
|
|
|
549
548
|
return field
|
|
550
549
|
|
|
551
550
|
|
|
552
|
-
async def get_field_by_name(self, name: str) -> '
|
|
551
|
+
async def get_field_by_name(self, name: str) -> 'AsyncField':
|
|
553
552
|
"""
|
|
554
553
|
[async] Get a specific field by its name.
|
|
555
554
|
|
|
@@ -557,16 +556,16 @@ class VectorLayer(AsyncBase):
|
|
|
557
556
|
name (str): The name of the field to retrieve.
|
|
558
557
|
|
|
559
558
|
Returns:
|
|
560
|
-
|
|
559
|
+
AsyncField: The requested field instance.
|
|
561
560
|
|
|
562
561
|
Raises:
|
|
563
562
|
NotFoundError: If the field with the specified name is not found.
|
|
564
563
|
|
|
565
564
|
Example:
|
|
566
565
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
567
|
-
>>> from geobox.aio.vectorlayer import
|
|
566
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
568
567
|
>>> async with AsyncGeoboxClient() as client:
|
|
569
|
-
>>> layer = await
|
|
568
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
570
569
|
>>> field = await layer.get_field_by_name(name='test')
|
|
571
570
|
"""
|
|
572
571
|
field = next((f for f in await self.get_fields() if f.name == name), None)
|
|
@@ -576,7 +575,7 @@ class VectorLayer(AsyncBase):
|
|
|
576
575
|
return field
|
|
577
576
|
|
|
578
577
|
|
|
579
|
-
async def add_field(self, name: str, data_type: 'FieldType', data: Dict = {}) -> '
|
|
578
|
+
async def add_field(self, name: str, data_type: 'FieldType', data: Dict = {}) -> 'AsyncField':
|
|
580
579
|
"""
|
|
581
580
|
[async] Add a new field to the layer.
|
|
582
581
|
|
|
@@ -586,30 +585,30 @@ class VectorLayer(AsyncBase):
|
|
|
586
585
|
data (Dict): Additional field properties (display_name, description, etc.).
|
|
587
586
|
|
|
588
587
|
Returns:
|
|
589
|
-
|
|
588
|
+
AsyncField: The newly created field instance.
|
|
590
589
|
|
|
591
590
|
Raises:
|
|
592
591
|
ValidationError: If the field data is invalid.
|
|
593
592
|
|
|
594
593
|
Example:
|
|
595
594
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
596
|
-
>>> from geobox.aio.vectorlayer import
|
|
595
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
597
596
|
>>> async with AsyncGeoboxClient() as client:
|
|
598
|
-
>>> layer = await
|
|
597
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
599
598
|
>>> field = await layer.add_field(name="new_field", data_type=FieldType.String)
|
|
600
599
|
"""
|
|
601
|
-
return await
|
|
600
|
+
return await AsyncField.create_field(self.api, layer=self, name=name, data_type=data_type, data=data)
|
|
602
601
|
|
|
603
602
|
|
|
604
603
|
async def calculate_field(self,
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
604
|
+
target_field: str,
|
|
605
|
+
expression: str,
|
|
606
|
+
q: str = None,
|
|
607
|
+
bbox: List = None,
|
|
608
|
+
bbox_srid: int = None,
|
|
609
|
+
feature_ids: List = None,
|
|
610
|
+
run_async: bool = True,
|
|
611
|
+
user_id: int = None) -> Union['AsyncTask', Dict]:
|
|
613
612
|
"""
|
|
614
613
|
[async] Calculate values for a field based on an expression.
|
|
615
614
|
|
|
@@ -624,20 +623,20 @@ class VectorLayer(AsyncBase):
|
|
|
624
623
|
user_id (int, optional): Specific user. privileges required.
|
|
625
624
|
|
|
626
625
|
Returns:
|
|
627
|
-
|
|
626
|
+
AsyncTask | Dict: The task instance of the calculation operation or the api response if the run_async=False.
|
|
628
627
|
|
|
629
628
|
Example:
|
|
630
629
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
631
|
-
>>> from geobox.aio.vectorlayer import
|
|
630
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
632
631
|
>>> async with AsyncGeoboxClient() as client:
|
|
633
|
-
>>> layer = await
|
|
632
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
634
633
|
>>> task = await layer.calculate_field(target_field="target_field",
|
|
635
|
-
...
|
|
636
|
-
...
|
|
637
|
-
...
|
|
638
|
-
...
|
|
639
|
-
...
|
|
640
|
-
...
|
|
634
|
+
... expression="expression",
|
|
635
|
+
... q="name like 'my_layer'",
|
|
636
|
+
... bbox=[10, 20, 30, 40],
|
|
637
|
+
... bbox_srid=3857,
|
|
638
|
+
... feature_ids=[1, 2, 3],
|
|
639
|
+
... run_async=True)
|
|
641
640
|
"""
|
|
642
641
|
data = clean_data({
|
|
643
642
|
"target_field": target_field,
|
|
@@ -653,13 +652,13 @@ class VectorLayer(AsyncBase):
|
|
|
653
652
|
endpoint = urljoin(self.endpoint, 'calculateField/')
|
|
654
653
|
response = await self.api.post(endpoint, data, is_json=False)
|
|
655
654
|
if run_async:
|
|
656
|
-
task = await
|
|
655
|
+
task = await AsyncTask.get_task(self.api, response.get('task_id'))
|
|
657
656
|
return task
|
|
658
657
|
|
|
659
658
|
return response
|
|
660
659
|
|
|
661
660
|
|
|
662
|
-
async def get_features(self, **kwargs) -> Union[List['
|
|
661
|
+
async def get_features(self, **kwargs) -> Union[List['AsyncFeature'], int]:
|
|
663
662
|
"""
|
|
664
663
|
[async] Get features from the layer with optional filtering and pagination.
|
|
665
664
|
|
|
@@ -686,17 +685,18 @@ class VectorLayer(AsyncBase):
|
|
|
686
685
|
|
|
687
686
|
Example:
|
|
688
687
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
689
|
-
>>> from geobox.aio.vectorlayer import
|
|
688
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
690
689
|
>>> async with AsyncGeoboxClient() as client:
|
|
691
|
-
>>> layer = await
|
|
692
|
-
>>> features = await layer.get_features(
|
|
693
|
-
...
|
|
694
|
-
...
|
|
695
|
-
...
|
|
696
|
-
...
|
|
697
|
-
...
|
|
698
|
-
...
|
|
699
|
-
...
|
|
690
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
691
|
+
>>> features = await layer.get_features(
|
|
692
|
+
... quant_factor=1000000,
|
|
693
|
+
... skip=0,
|
|
694
|
+
... limit=100,
|
|
695
|
+
... skip_geometry=False,
|
|
696
|
+
... return_count=False,
|
|
697
|
+
... select_fields="fclass, osm_id",
|
|
698
|
+
... out_srid=3857,
|
|
699
|
+
... bbox_srid=3857)
|
|
700
700
|
"""
|
|
701
701
|
params = {
|
|
702
702
|
'f': 'json',
|
|
@@ -719,13 +719,13 @@ class VectorLayer(AsyncBase):
|
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
return await super()._get_list(api=self.api,
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
722
|
+
endpoint=f'{self.endpoint}features/',
|
|
723
|
+
params=params,
|
|
724
|
+
factory_func=lambda api, item, srid: AsyncFeature(self, srid, item),
|
|
725
|
+
geojson=True)
|
|
726
726
|
|
|
727
727
|
|
|
728
|
-
async def get_feature(self, feature_id: int, out_srid: int =
|
|
728
|
+
async def get_feature(self, feature_id: int, out_srid: int = AsyncFeature.BASE_SRID) -> 'AsyncFeature':
|
|
729
729
|
"""
|
|
730
730
|
[async] Get a specific feature by its ID.
|
|
731
731
|
|
|
@@ -741,21 +741,21 @@ class VectorLayer(AsyncBase):
|
|
|
741
741
|
|
|
742
742
|
Example:
|
|
743
743
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
744
|
-
>>> from geobox.aio.vectorlayer import
|
|
744
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
745
745
|
>>> async with AsyncGeoboxClient() as client:
|
|
746
|
-
>>> layer = await
|
|
746
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
747
747
|
>>> feature = await layer.get_feature(feature_id=1, out_srid=4326)
|
|
748
748
|
"""
|
|
749
749
|
endpoint = f"{self.endpoint}features/{feature_id}"
|
|
750
750
|
response = await self.api.get(endpoint)
|
|
751
|
-
feature =
|
|
752
|
-
if out_srid !=
|
|
751
|
+
feature = AsyncFeature(self, data=response)
|
|
752
|
+
if out_srid != AsyncFeature.BASE_SRID:
|
|
753
753
|
feature.transform(out_srid)
|
|
754
754
|
|
|
755
755
|
return feature
|
|
756
756
|
|
|
757
757
|
|
|
758
|
-
async def create_feature(self, geojson: Dict)-> '
|
|
758
|
+
async def create_feature(self, geojson: Dict)-> 'AsyncFeature':
|
|
759
759
|
"""
|
|
760
760
|
[async] Create a new feature in the layer.
|
|
761
761
|
|
|
@@ -770,9 +770,9 @@ class VectorLayer(AsyncBase):
|
|
|
770
770
|
|
|
771
771
|
Example:
|
|
772
772
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
773
|
-
>>> from geobox.aio.vectorlayer import
|
|
773
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
774
774
|
>>> async with AsyncGeoboxClient() as client:
|
|
775
|
-
>>> layer = await
|
|
775
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
776
776
|
>>> geojson = {
|
|
777
777
|
... "type": "Feature",
|
|
778
778
|
... "geometry": {"type": "Point", "coordinates": [10, 20]},
|
|
@@ -780,11 +780,16 @@ class VectorLayer(AsyncBase):
|
|
|
780
780
|
... }
|
|
781
781
|
>>> feature = await layer.create_feature(geojson=geojson)
|
|
782
782
|
"""
|
|
783
|
-
return await
|
|
783
|
+
return await AsyncFeature.create_feature(self, geojson)
|
|
784
784
|
|
|
785
785
|
|
|
786
|
-
async def delete_features(self,
|
|
787
|
-
|
|
786
|
+
async def delete_features(self,
|
|
787
|
+
q: str = None,
|
|
788
|
+
bbox: str = None,
|
|
789
|
+
bbox_srid: int = None,
|
|
790
|
+
feature_ids: List[int] = None,
|
|
791
|
+
run_async: bool = True,
|
|
792
|
+
user_id: int = None) -> Union['AsyncTask', Dict]:
|
|
788
793
|
"""
|
|
789
794
|
[async] Delete features from the layer based on specified criteria.
|
|
790
795
|
|
|
@@ -797,21 +802,21 @@ class VectorLayer(AsyncBase):
|
|
|
797
802
|
user_id (int, optional): Specific user. privileges required.
|
|
798
803
|
|
|
799
804
|
Returns:
|
|
800
|
-
|
|
805
|
+
AsyncTask | Dict: The task instance of the deletion operation or the api response if run_async=False.
|
|
801
806
|
|
|
802
807
|
Raises:
|
|
803
808
|
ValidationError: If the deletion parameters are invalid.
|
|
804
809
|
|
|
805
810
|
Example:
|
|
806
811
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
807
|
-
>>> from geobox.aio.vectorlayer import
|
|
812
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
808
813
|
>>> async with AsyncGeoboxClient() as client:
|
|
809
|
-
>>> layer = await
|
|
814
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
810
815
|
>>> await layer.delete_features(q="name like 'my_layer'",
|
|
811
|
-
...
|
|
812
|
-
...
|
|
813
|
-
...
|
|
814
|
-
...
|
|
816
|
+
... bbox='10, 20, 30, 40',
|
|
817
|
+
... bbox_srid=3857,
|
|
818
|
+
... feature_ids='1, 2, 3',
|
|
819
|
+
... run_async=True)
|
|
815
820
|
"""
|
|
816
821
|
data = clean_data({
|
|
817
822
|
"q": q,
|
|
@@ -825,22 +830,22 @@ class VectorLayer(AsyncBase):
|
|
|
825
830
|
endpoint = urljoin(self.endpoint, 'deleteFeatures/')
|
|
826
831
|
response = await self.api.post(endpoint, data, is_json=False)
|
|
827
832
|
if run_async:
|
|
828
|
-
task = await
|
|
833
|
+
task = await AsyncTask.get_task(self.api, response.get('task_id'))
|
|
829
834
|
return task
|
|
830
835
|
|
|
831
836
|
return response
|
|
832
837
|
|
|
833
838
|
|
|
834
839
|
async def import_features(self,
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
840
|
+
file: 'AsyncFile',
|
|
841
|
+
input_geom_type: 'InputGeomType' = None,
|
|
842
|
+
input_layer_name: str = None,
|
|
843
|
+
input_dataset: str = None,
|
|
844
|
+
user_id: int = None,
|
|
845
|
+
input_srid: int = None,
|
|
846
|
+
file_encoding: str = "utf-8",
|
|
847
|
+
replace_domain_codes_by_values: bool = False,
|
|
848
|
+
report_errors: bool = True) -> 'AsyncTask':
|
|
844
849
|
"""
|
|
845
850
|
[async] Import features from a file into the layer.
|
|
846
851
|
|
|
@@ -856,25 +861,25 @@ class VectorLayer(AsyncBase):
|
|
|
856
861
|
report_errors (bool, optional): Whether to report import errors.
|
|
857
862
|
|
|
858
863
|
Returns:
|
|
859
|
-
|
|
864
|
+
AsyncTask: The task instance of the import operation.
|
|
860
865
|
|
|
861
866
|
Raises:
|
|
862
867
|
ValidationError: If the import parameters are invalid.
|
|
863
868
|
|
|
864
869
|
Example:
|
|
865
870
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
866
|
-
>>> from geobox.aio.vectorlayer import
|
|
871
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
867
872
|
>>> async with AsyncGeoboxClient() as client:
|
|
868
|
-
>>> layer = await
|
|
873
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
869
874
|
>>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
|
|
870
875
|
>>> task = await layer.import_features(file=file,
|
|
871
|
-
...
|
|
872
|
-
...
|
|
873
|
-
...
|
|
874
|
-
...
|
|
875
|
-
...
|
|
876
|
-
...
|
|
877
|
-
...
|
|
876
|
+
... input_geom_type=InputGeomType.POINT,
|
|
877
|
+
... input_layer_name="my_layer",
|
|
878
|
+
... input_dataset="my_dataset",
|
|
879
|
+
... input_srid=3857,
|
|
880
|
+
... file_encoding="utf-8",
|
|
881
|
+
... replace_domain_codes_by_values=False,
|
|
882
|
+
... report_errors=True)
|
|
878
883
|
"""
|
|
879
884
|
data = clean_data({
|
|
880
885
|
"file_uuid": file.uuid,
|
|
@@ -890,21 +895,21 @@ class VectorLayer(AsyncBase):
|
|
|
890
895
|
|
|
891
896
|
endpoint = urljoin(self.endpoint, 'import/')
|
|
892
897
|
response = await self.api.post(endpoint, data, is_json=False)
|
|
893
|
-
task = await
|
|
898
|
+
task = await AsyncTask.get_task(self.api, response.get('task_id'))
|
|
894
899
|
return task
|
|
895
900
|
|
|
896
901
|
|
|
897
902
|
async def export_features(self,
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
903
|
+
out_filename: str,
|
|
904
|
+
out_format: 'FileOutputFormat',
|
|
905
|
+
replace_domain_codes_by_values: bool = False,
|
|
906
|
+
run_async: bool = True,
|
|
907
|
+
bbox: List[float] = None,
|
|
908
|
+
out_srid: int = None,
|
|
909
|
+
zipped: bool = True,
|
|
910
|
+
feature_ids: List[int] = None,
|
|
911
|
+
bbox_srid: int = None,
|
|
912
|
+
q: str = None, fields: List[str] = None) -> Union['AsyncTask', Dict]:
|
|
908
913
|
"""
|
|
909
914
|
[async] Export features from the layer to a file.
|
|
910
915
|
|
|
@@ -922,24 +927,24 @@ class VectorLayer(AsyncBase):
|
|
|
922
927
|
fields (List[str], optional): List of fields to include in the export.
|
|
923
928
|
|
|
924
929
|
Returns:
|
|
925
|
-
|
|
930
|
+
AsyncTask | Dict: The task instance of the export operation or the api response if run_async=False.
|
|
926
931
|
|
|
927
932
|
Raises:
|
|
928
933
|
ValidationError: If the export parameters are invalid.
|
|
929
934
|
|
|
930
935
|
Example:
|
|
931
936
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
932
|
-
>>> from geobox.aio.vectorlayer import
|
|
937
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
933
938
|
>>> async with AsyncGeoboxClient() as client:
|
|
934
|
-
>>> layer = await
|
|
939
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
935
940
|
>>> task = await layer.export_features(out_filename="output.shp",
|
|
936
|
-
...
|
|
937
|
-
...
|
|
938
|
-
...
|
|
939
|
-
...
|
|
940
|
-
...
|
|
941
|
-
...
|
|
942
|
-
...
|
|
941
|
+
... out_format="shp",
|
|
942
|
+
... replace_domain_codes_by_values=False,
|
|
943
|
+
... run_async=True,
|
|
944
|
+
... bbox=[10, 20, 30, 40],
|
|
945
|
+
... out_srid=3857,
|
|
946
|
+
... zipped=True,
|
|
947
|
+
... feature_ids=[1, 2, 3])
|
|
943
948
|
"""
|
|
944
949
|
data = clean_data({
|
|
945
950
|
"replace_domain_codes_by_values": replace_domain_codes_by_values,
|
|
@@ -958,14 +963,19 @@ class VectorLayer(AsyncBase):
|
|
|
958
963
|
endpoint = urljoin(self.endpoint, 'export/')
|
|
959
964
|
response = await self.api.post(endpoint, data, is_json=False)
|
|
960
965
|
if run_async:
|
|
961
|
-
task = await
|
|
966
|
+
task = await AsyncTask.get_task(self.api, response.get('task_id'))
|
|
962
967
|
return task
|
|
963
968
|
|
|
964
969
|
return response
|
|
965
970
|
|
|
966
971
|
|
|
967
|
-
async def create_view(self,
|
|
968
|
-
|
|
972
|
+
async def create_view(self,
|
|
973
|
+
name: str,
|
|
974
|
+
display_name: str = None,
|
|
975
|
+
description: str = None,
|
|
976
|
+
view_filter: str = None,
|
|
977
|
+
view_extent: Dict = None,
|
|
978
|
+
view_cols: str = None) -> 'AsyncVectorLayerView':
|
|
969
979
|
"""
|
|
970
980
|
[async] Create a view of the vector layer.
|
|
971
981
|
|
|
@@ -978,24 +988,24 @@ class VectorLayer(AsyncBase):
|
|
|
978
988
|
view_cols (str, optional): The columns to include in the view.
|
|
979
989
|
|
|
980
990
|
Returns:
|
|
981
|
-
|
|
991
|
+
AsyncVectorLayerView: The created view instance.
|
|
982
992
|
|
|
983
993
|
Raises:
|
|
984
994
|
ValidationError: If the view parameters are invalid.
|
|
985
995
|
|
|
986
996
|
Example:
|
|
987
997
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
988
|
-
>>> from geobox.aio.vectorlayer import
|
|
998
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
989
999
|
>>> async with AsyncGeoboxClient() as client:
|
|
990
|
-
>>> layer = await
|
|
1000
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
991
1001
|
>>> view = await layer.create_view(name="my_view",
|
|
992
|
-
...
|
|
993
|
-
...
|
|
994
|
-
...
|
|
995
|
-
...
|
|
996
|
-
...
|
|
1002
|
+
... display_name="My View",
|
|
1003
|
+
... description="This is a view of my layer",
|
|
1004
|
+
... view_filter="province_name = 'Tehran'",
|
|
1005
|
+
... view_extent=[10, 20, 30, 40],
|
|
1006
|
+
... view_cols="[ALL]")
|
|
997
1007
|
"""
|
|
998
|
-
from .view import
|
|
1008
|
+
from .view import AsyncVectorLayerView
|
|
999
1009
|
|
|
1000
1010
|
data = {
|
|
1001
1011
|
"name": name,
|
|
@@ -1007,9 +1017,9 @@ class VectorLayer(AsyncBase):
|
|
|
1007
1017
|
}
|
|
1008
1018
|
|
|
1009
1019
|
return await super()._create(api=self.api,
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1020
|
+
endpoint=f'{self.endpoint}views/',
|
|
1021
|
+
data=data,
|
|
1022
|
+
factory_func=lambda api, item: AsyncVectorLayerView(api, item['uuid'], self.layer_type, item))
|
|
1013
1023
|
|
|
1014
1024
|
|
|
1015
1025
|
def get_tile_pbf_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}') -> str:
|
|
@@ -1026,9 +1036,9 @@ class VectorLayer(AsyncBase):
|
|
|
1026
1036
|
|
|
1027
1037
|
Example:
|
|
1028
1038
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1029
|
-
>>> from geobox.aio.vectorlayer import
|
|
1039
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1030
1040
|
>>> async with AsyncGeoboxClient() as client:
|
|
1031
|
-
>>> layer = await
|
|
1041
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1032
1042
|
>>> tile = layer.get_tile(x=10, y=20, z=1)
|
|
1033
1043
|
"""
|
|
1034
1044
|
endpoint = f'{self.api.base_url}{self.endpoint}tiles/{z}/{x}/{y}.pbf'
|
|
@@ -1048,9 +1058,9 @@ class VectorLayer(AsyncBase):
|
|
|
1048
1058
|
|
|
1049
1059
|
Example:
|
|
1050
1060
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1051
|
-
>>> from geobox.aio.vectorlayer import
|
|
1061
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1052
1062
|
>>> async with AsyncGeoboxClient() as client:
|
|
1053
|
-
>>> layer = await
|
|
1063
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1054
1064
|
>>> tile_json = await layer.get_tile_json()
|
|
1055
1065
|
"""
|
|
1056
1066
|
endpoint = urljoin(self.endpoint, 'tilejson.json')
|
|
@@ -1067,9 +1077,9 @@ class VectorLayer(AsyncBase):
|
|
|
1067
1077
|
|
|
1068
1078
|
Example:
|
|
1069
1079
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1070
|
-
>>> from geobox.aio.vectorlayer import
|
|
1080
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1071
1081
|
>>> async with AsyncGeoboxClient() as client:
|
|
1072
|
-
>>> layer = await
|
|
1082
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1073
1083
|
>>> setting = await layer.setting
|
|
1074
1084
|
"""
|
|
1075
1085
|
return await super()._get_settings(endpoint=self.endpoint)
|
|
@@ -1086,7 +1096,6 @@ class VectorLayer(AsyncBase):
|
|
|
1086
1096
|
|
|
1087
1097
|
Example:
|
|
1088
1098
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1089
|
-
>>> from geobox.aio.vectorlayer import VectorLayer
|
|
1090
1099
|
>>> async with AsyncGeoboxClient() as client:
|
|
1091
1100
|
>>> layer1 = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
1092
1101
|
>>> layer2 = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
@@ -1124,24 +1133,24 @@ class VectorLayer(AsyncBase):
|
|
|
1124
1133
|
|
|
1125
1134
|
Example:
|
|
1126
1135
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1127
|
-
>>> from geobox.aio.vectorlayer import
|
|
1136
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1128
1137
|
>>> async with AsyncGeoboxClient() as client:
|
|
1129
|
-
>>> layer = await
|
|
1138
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1130
1139
|
>>> await layer.set_settings(title_field="name",
|
|
1131
|
-
...
|
|
1132
|
-
...
|
|
1133
|
-
...
|
|
1134
|
-
...
|
|
1135
|
-
...
|
|
1136
|
-
...
|
|
1137
|
-
...
|
|
1138
|
-
...
|
|
1139
|
-
...
|
|
1140
|
-
...
|
|
1141
|
-
...
|
|
1142
|
-
...
|
|
1143
|
-
...
|
|
1144
|
-
...
|
|
1140
|
+
... domain_display_type="Value",
|
|
1141
|
+
... allow_export=True,
|
|
1142
|
+
... editable=True,
|
|
1143
|
+
... edit_geometry=True,
|
|
1144
|
+
... editable_attributes="[ALL]",
|
|
1145
|
+
... allow_insert=True,
|
|
1146
|
+
... allow_delete=True,
|
|
1147
|
+
... min_zoom=0,
|
|
1148
|
+
... max_zoom=24,
|
|
1149
|
+
... max_features=65536,
|
|
1150
|
+
... filter_features=True,
|
|
1151
|
+
... fields=["id"],
|
|
1152
|
+
... use_cache=True,
|
|
1153
|
+
... cache_until_zoom=17)
|
|
1145
1154
|
"""
|
|
1146
1155
|
general_settings = {'title_field', 'domain_display_type', 'allow_export'}
|
|
1147
1156
|
edit_settings = {'editable', 'edit_geometry', 'editable_attributes', 'allow_insert', 'allow_delete'}
|
|
@@ -1160,7 +1169,7 @@ class VectorLayer(AsyncBase):
|
|
|
1160
1169
|
return await super()._set_settings(endpoint=self.endpoint, data=settings)
|
|
1161
1170
|
|
|
1162
1171
|
|
|
1163
|
-
async def seed_cache(self, from_zoom: int = None, to_zoom: int = None, ignore_cache: bool = False, workers: int = 1, user_id: int = None) -> List['
|
|
1172
|
+
async def seed_cache(self, from_zoom: int = None, to_zoom: int = None, ignore_cache: bool = False, workers: int = 1, user_id: int = None) -> List['AsyncTask']:
|
|
1164
1173
|
"""
|
|
1165
1174
|
[async] Seed the cache for the layer.
|
|
1166
1175
|
|
|
@@ -1172,13 +1181,13 @@ class VectorLayer(AsyncBase):
|
|
|
1172
1181
|
user_id (int, optional): Specific user. privileges required.
|
|
1173
1182
|
|
|
1174
1183
|
Returns:
|
|
1175
|
-
List[
|
|
1184
|
+
List[AsyncTask]: The task instance of the cache seeding operation.
|
|
1176
1185
|
|
|
1177
1186
|
Example:
|
|
1178
1187
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1179
|
-
>>> from geobox.aio.vectorlayer import
|
|
1188
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1180
1189
|
>>> async with AsyncGeoboxClient() as client:
|
|
1181
|
-
>>> layer = await
|
|
1190
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1182
1191
|
>>> task = await layer.seed_cache(from_zoom=0, to_zoom=10, ignore_cache=False, workers=1)
|
|
1183
1192
|
"""
|
|
1184
1193
|
data = {
|
|
@@ -1200,9 +1209,9 @@ class VectorLayer(AsyncBase):
|
|
|
1200
1209
|
|
|
1201
1210
|
Example:
|
|
1202
1211
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1203
|
-
>>> from geobox.aio.vectorlayer import
|
|
1212
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1204
1213
|
>>> async with AsyncGeoboxClient() as client:
|
|
1205
|
-
>>> layer = await
|
|
1214
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1206
1215
|
>>> await layer.clear_cache()
|
|
1207
1216
|
"""
|
|
1208
1217
|
await super()._clear_cache(endpoint=self.endpoint)
|
|
@@ -1218,9 +1227,9 @@ class VectorLayer(AsyncBase):
|
|
|
1218
1227
|
|
|
1219
1228
|
Example:
|
|
1220
1229
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1221
|
-
>>> from geobox.aio.vectorlayer import
|
|
1230
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1222
1231
|
>>> async with AsyncGeoboxClient() as client:
|
|
1223
|
-
>>> layer = await
|
|
1232
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1224
1233
|
>>> await layer.cache_size
|
|
1225
1234
|
"""
|
|
1226
1235
|
return await super()._cache_size(endpoint=self.endpoint)
|
|
@@ -1235,9 +1244,9 @@ class VectorLayer(AsyncBase):
|
|
|
1235
1244
|
|
|
1236
1245
|
Example:
|
|
1237
1246
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1238
|
-
>>> from geobox.aio.vectorlayer import
|
|
1247
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1239
1248
|
>>> async with AsyncGeoboxClient() as client:
|
|
1240
|
-
>>> layer = await
|
|
1249
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1241
1250
|
>>> await layer.update_stats()
|
|
1242
1251
|
"""
|
|
1243
1252
|
endpoint = urljoin(self.endpoint, 'updateStats/')
|
|
@@ -1253,16 +1262,16 @@ class VectorLayer(AsyncBase):
|
|
|
1253
1262
|
|
|
1254
1263
|
Example:
|
|
1255
1264
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1256
|
-
>>> from geobox.aio.vectorlayer import
|
|
1265
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1257
1266
|
>>> async with AsyncGeoboxClient() as client:
|
|
1258
|
-
>>> layer = await
|
|
1267
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1259
1268
|
>>> await layer.prune_edited_areas()
|
|
1260
1269
|
"""
|
|
1261
1270
|
endpoint = urljoin(self.endpoint, 'prune/')
|
|
1262
1271
|
return await self.api.post(endpoint)
|
|
1263
1272
|
|
|
1264
1273
|
|
|
1265
|
-
async def get_attachments(self, **kwargs) -> List['
|
|
1274
|
+
async def get_attachments(self, **kwargs) -> List['AsyncAttachment']:
|
|
1266
1275
|
"""
|
|
1267
1276
|
[async] Get the resouces attachments
|
|
1268
1277
|
|
|
@@ -1275,31 +1284,31 @@ class VectorLayer(AsyncBase):
|
|
|
1275
1284
|
return_count (bool): Whether to return total count. default is False.
|
|
1276
1285
|
|
|
1277
1286
|
Returns:
|
|
1278
|
-
List[
|
|
1287
|
+
List[AsyncAttachment] | int: A list of attachments instances or the total number of attachments.
|
|
1279
1288
|
|
|
1280
1289
|
Raises:
|
|
1281
1290
|
TypeError: if the resource type is not supported
|
|
1282
1291
|
|
|
1283
1292
|
Example:
|
|
1284
1293
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1285
|
-
>>> from geobox.aio.vectorlayer import
|
|
1294
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1286
1295
|
>>> async with AsyncGeoboxClient() as client:
|
|
1287
|
-
>>> layer = await
|
|
1296
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1288
1297
|
>>> await layer.get_attachments()
|
|
1289
1298
|
"""
|
|
1290
|
-
from .attachment import
|
|
1299
|
+
from .attachment import AsyncAttachment
|
|
1291
1300
|
|
|
1292
|
-
return await
|
|
1301
|
+
return await AsyncAttachment.get_attachments(self.api, resource=self, **kwargs)
|
|
1293
1302
|
|
|
1294
1303
|
|
|
1295
1304
|
async def create_attachment(self,
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1305
|
+
name: str,
|
|
1306
|
+
loc_x: int,
|
|
1307
|
+
loc_y: int,
|
|
1308
|
+
file: 'AsyncFile',
|
|
1309
|
+
feature: 'AsyncFeature' = None,
|
|
1310
|
+
display_name: str = None,
|
|
1311
|
+
description: str = None) -> 'AsyncAttachment':
|
|
1303
1312
|
"""
|
|
1304
1313
|
[async] Create a new Attachment.
|
|
1305
1314
|
|
|
@@ -1313,158 +1322,51 @@ class VectorLayer(AsyncBase):
|
|
|
1313
1322
|
description (str, optional): The description of the scene.
|
|
1314
1323
|
|
|
1315
1324
|
Returns:
|
|
1316
|
-
|
|
1325
|
+
AsyncAttachment: The newly created Attachment instance.
|
|
1317
1326
|
|
|
1318
1327
|
Raises:
|
|
1319
1328
|
ValidationError: If the Attachment data is invalid.
|
|
1320
1329
|
|
|
1321
1330
|
Example:
|
|
1322
1331
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1323
|
-
>>> from geobox.aio.vectorlayer import
|
|
1332
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1324
1333
|
>>> async with AsyncGeoboxClient() as client:
|
|
1325
|
-
>>> layer = await
|
|
1334
|
+
>>> layer = await AsyncVectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1326
1335
|
>>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
|
|
1327
1336
|
>>> await layer.create_attachment(name='test', loc_x=10, loc_y=10, file=file)
|
|
1328
1337
|
"""
|
|
1329
|
-
from .attachment import
|
|
1330
|
-
|
|
1331
|
-
return await
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1338
|
+
from .attachment import AsyncAttachment
|
|
1339
|
+
|
|
1340
|
+
return await AsyncAttachment.create_attachment(self.api,
|
|
1341
|
+
name=name,
|
|
1342
|
+
loc_x=loc_x,
|
|
1343
|
+
loc_y=loc_y,
|
|
1344
|
+
resource=self,
|
|
1345
|
+
file=file,
|
|
1346
|
+
feature=feature,
|
|
1347
|
+
display_name=display_name,
|
|
1348
|
+
description=description)
|
|
1340
1349
|
|
|
1341
1350
|
|
|
1342
|
-
def to_sync(self, sync_client: '
|
|
1351
|
+
def to_sync(self, sync_client: 'GeoboxClient') -> 'VectorLayer':
|
|
1343
1352
|
"""
|
|
1344
1353
|
Switch to sync version of the vector layer instance to have access to the sync methods
|
|
1345
1354
|
|
|
1346
1355
|
Args:
|
|
1347
|
-
sync_client (
|
|
1356
|
+
sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
1348
1357
|
|
|
1349
1358
|
Returns:
|
|
1350
|
-
|
|
1359
|
+
VectorLayer: the sync instance of the vector layer.
|
|
1351
1360
|
|
|
1352
1361
|
Example:
|
|
1353
1362
|
>>> from geobox import Geoboxclient
|
|
1354
1363
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
1355
|
-
>>> from geobox.aio.vectorlayer import
|
|
1364
|
+
>>> from geobox.aio.vectorlayer import AsyncVectorLayer
|
|
1356
1365
|
>>> client = GeoboxClient()
|
|
1357
1366
|
>>> async with AsyncGeoboxClient() as async_client:
|
|
1358
|
-
>>> layer = await
|
|
1367
|
+
>>> layer = await AsyncVectorLayer.get_vector(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1359
1368
|
>>> sync_layer = layer.to_sync(client)
|
|
1360
1369
|
"""
|
|
1361
|
-
from ..vectorlayer import VectorLayer
|
|
1362
|
-
|
|
1363
|
-
return SyncVectorLayer(api=sync_client, uuid=self.uuid, layer_type=self.layer_type, data=self.data)
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
async def rasterize(self,
|
|
1369
|
-
output_raster_name: str,
|
|
1370
|
-
pixel_size: int = 10,
|
|
1371
|
-
nodata: Optional[int] = -9999,
|
|
1372
|
-
data_type: Optional[AnalysisDataType] = AnalysisDataType.int16,
|
|
1373
|
-
burn_value: Optional[int] = 1,
|
|
1374
|
-
burn_attribute: Optional[str] = None,
|
|
1375
|
-
user_id: Optional[int] = None) -> 'Task':
|
|
1376
|
-
"""
|
|
1377
|
-
[async] Rasterize a vector layer.
|
|
1378
|
-
|
|
1379
|
-
This method converts a vector layer (or view) to a raster dataset using the specified parameters.
|
|
1380
|
-
You can control the output raster's name, pixel size, data type, nodata value, and the value to burn (either a constant or from an attribute field).
|
|
1381
|
-
Only users with Publisher role or higher can perform this operation.
|
|
1382
|
-
|
|
1383
|
-
Args:
|
|
1384
|
-
output_raster_name (str): Name for the output raster dataset
|
|
1385
|
-
pixel_size (int, optional): Pixel size for the output raster (must be > 0). default: 10
|
|
1386
|
-
nodata (int, optional): NoData value to use in the output raster. default: -9999
|
|
1387
|
-
data_type (AnalysisDataType, optional): Data type for the output raster (e.g., int16, float32). default: AnalysisDataType.int16
|
|
1388
|
-
burn_value (int, optional): Value to burn into the raster for all features (if burn_attribute is not set). default: 1
|
|
1389
|
-
burn_attribute (str, optional): Name of the attribute field to use for burning values into the raster
|
|
1390
|
-
user_id (int, optional): specific user. priviledges required!
|
|
1391
|
-
|
|
1392
|
-
Returns:
|
|
1393
|
-
Task: task instance of the process
|
|
1370
|
+
from ..vectorlayer import VectorLayer
|
|
1394
1371
|
|
|
1395
|
-
|
|
1396
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
1397
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
1398
|
-
>>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
1399
|
-
>>> task = await vector.rasterize(output_raster_name='test')
|
|
1400
|
-
"""
|
|
1401
|
-
from .analysis import Analysis
|
|
1402
|
-
return await Analysis.rasterize(self.api,
|
|
1403
|
-
self,
|
|
1404
|
-
output_raster_name=output_raster_name,
|
|
1405
|
-
burn_attribute=burn_attribute,
|
|
1406
|
-
pixel_size=pixel_size,
|
|
1407
|
-
nodata=nodata,
|
|
1408
|
-
data_type=data_type,
|
|
1409
|
-
burn_value=burn_value,
|
|
1410
|
-
user_id=user_id)
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
async def idw_interpolation(self,
|
|
1414
|
-
output_raster_name: str,
|
|
1415
|
-
z_field: Field,
|
|
1416
|
-
match_raster_uuid: Optional[str] = None,
|
|
1417
|
-
pixel_size: int = 10,
|
|
1418
|
-
extent: Optional[str] = None,
|
|
1419
|
-
power: float = 2.0,
|
|
1420
|
-
smoothing: float = 0.0,
|
|
1421
|
-
max_points: int = 16,
|
|
1422
|
-
radius: int = 1000,
|
|
1423
|
-
nodata: int = -9999,
|
|
1424
|
-
out_dtype: AnalysisDataType = AnalysisDataType.float32,
|
|
1425
|
-
user_id: Optional[int] = None) -> 'Task':
|
|
1426
|
-
"""
|
|
1427
|
-
[async] Create an IDW (Inverse Distance Weighting) interpolation raster from point data.
|
|
1428
|
-
|
|
1429
|
-
it creates a raster using IDW interpolation from point data in a vector layer.
|
|
1430
|
-
Only users with Publisher role or higher can perform this operation.
|
|
1431
|
-
|
|
1432
|
-
Args:
|
|
1433
|
-
output_raster_name (str): Name for the output IDW raster dataset.
|
|
1434
|
-
z_field (Field): the field containing the values to interpolate.
|
|
1435
|
-
match_raster_uuid (str, optional): UUID of reference raster to match resolution/extent.
|
|
1436
|
-
pixel_size (int, optional): Pixel size for the output raster. default: 10
|
|
1437
|
-
extent (str, optional): Extent as 'minX,minY,maxX,maxY'.
|
|
1438
|
-
power (float, optional): Power parameter for IDW. default: 2.0
|
|
1439
|
-
smoothing (float, optional): Smoothing parameter for IDW. default: 0.0
|
|
1440
|
-
max_points (int, optional): Maximum number of neighbors to use. default: 16
|
|
1441
|
-
radius (int, optional): Search radius in map units. default: 1000
|
|
1442
|
-
nodata (int, optional): NoData value for the output raster. default: -9999
|
|
1443
|
-
out_dtype (AnalysisDataType, optional): Output data type.
|
|
1444
|
-
user_id (int, optional): specific user. priviledges required!
|
|
1445
|
-
|
|
1446
|
-
Returns:
|
|
1447
|
-
Task: task instance of the process
|
|
1448
|
-
|
|
1449
|
-
Example:
|
|
1450
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
1451
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
1452
|
-
>>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
1453
|
-
>>> field = await vector.get_field_by_name('field_name')
|
|
1454
|
-
>>> task = await vector.idw(output_raster_name='test', z_field=field)
|
|
1455
|
-
"""
|
|
1456
|
-
from .analysis import Analysis
|
|
1457
|
-
return await Analysis.idw_interpolation(self.api,
|
|
1458
|
-
self,
|
|
1459
|
-
output_raster_name=output_raster_name,
|
|
1460
|
-
z_field=z_field,
|
|
1461
|
-
match_raster_uuid=match_raster_uuid,
|
|
1462
|
-
pixel_size=pixel_size,
|
|
1463
|
-
extent=extent,
|
|
1464
|
-
power=power,
|
|
1465
|
-
smoothing=smoothing,
|
|
1466
|
-
max_points=max_points,
|
|
1467
|
-
radius=radius,
|
|
1468
|
-
nodata=nodata,
|
|
1469
|
-
out_dtype=out_dtype,
|
|
1470
|
-
user_id=user_id)
|
|
1372
|
+
return VectorLayer(api=sync_client, uuid=self.uuid, layer_type=self.layer_type, data=self.data)
|