geobox 2.1.0__py3-none-any.whl → 2.2.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 +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 +35 -35
- 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 +31 -10
- 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.1.dist-info}/METADATA +15 -1
- geobox-2.2.1.dist-info/RECORD +72 -0
- geobox-2.1.0.dist-info/RECORD +0 -70
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/WHEEL +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/top_level.txt +0 -0
geobox/aio/feature.py
CHANGED
|
@@ -6,18 +6,18 @@ from ..enums import FeatureType
|
|
|
6
6
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from .vectorlayer import VectorLayer
|
|
9
|
-
from ..api import GeoboxClient
|
|
10
|
-
from ..feature import Feature
|
|
9
|
+
from ..api import GeoboxClient
|
|
10
|
+
from ..feature import Feature
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class AsyncFeature(AsyncBase):
|
|
14
14
|
|
|
15
15
|
BASE_SRID = 3857
|
|
16
16
|
|
|
17
17
|
def __init__(self,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
layer: 'VectorLayer',
|
|
19
|
+
srid: Optional[int] = 3857,
|
|
20
|
+
data: Optional[Dict] = {}):
|
|
21
21
|
"""
|
|
22
22
|
Constructs all the necessary attributes for the Feature object.
|
|
23
23
|
|
|
@@ -25,13 +25,6 @@ class Feature(AsyncBase):
|
|
|
25
25
|
layer (VectorLayer): The vector layer this feature belongs to
|
|
26
26
|
srid (int, optional): The Spatial Reference System Identifier (default is 3857)
|
|
27
27
|
data (Dict, optional): The feature data contains the feature geometry and properties
|
|
28
|
-
|
|
29
|
-
Example:
|
|
30
|
-
>>> from geobox import GeoboxClient, Feature
|
|
31
|
-
>>> client = GeoboxClient()
|
|
32
|
-
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
33
|
-
>>> feature = Feature(layer=layer, srid=4326) # example srid set to 4326
|
|
34
|
-
>>> feature.save()
|
|
35
28
|
"""
|
|
36
29
|
super().__init__(api=layer.api)
|
|
37
30
|
self.layer = layer
|
|
@@ -65,7 +58,8 @@ class Feature(AsyncBase):
|
|
|
65
58
|
Returns:
|
|
66
59
|
str: A string representation of the Feature object.
|
|
67
60
|
"""
|
|
68
|
-
|
|
61
|
+
feature_id = getattr(self, "id", "-1")
|
|
62
|
+
return f"AsyncFeature(id={feature_id}, type={self.feature_type})"
|
|
69
63
|
|
|
70
64
|
|
|
71
65
|
def __getattr__(self, name: str) -> Any:
|
|
@@ -217,18 +211,27 @@ class Feature(AsyncBase):
|
|
|
217
211
|
>>> await feature.save()
|
|
218
212
|
"""
|
|
219
213
|
data = self.data.copy()
|
|
214
|
+
srid = self.srid
|
|
215
|
+
|
|
220
216
|
try:
|
|
221
217
|
if self.id:
|
|
222
218
|
if self.srid != self.BASE_SRID:
|
|
223
|
-
self
|
|
219
|
+
self = self.transform(self.BASE_SRID)
|
|
220
|
+
self.data['geometry'] = self.original_geometry
|
|
224
221
|
await self.update(self.data)
|
|
225
222
|
self.coordinates = data['geometry']['coordinates']
|
|
226
223
|
except AttributeError:
|
|
224
|
+
if self.srid != self.BASE_SRID:
|
|
225
|
+
self = self.transform(self.BASE_SRID)
|
|
227
226
|
endpoint = urljoin(self.layer.endpoint, 'features/')
|
|
228
|
-
|
|
227
|
+
request_data = self.data.copy()
|
|
228
|
+
response = await self.layer.api.post(endpoint, request_data)
|
|
229
229
|
self.endpoint = urljoin(self.layer.endpoint, f'features/{response["id"]}/')
|
|
230
230
|
self.data.update(response)
|
|
231
231
|
|
|
232
|
+
self.data['geometry'] = data['geometry']
|
|
233
|
+
self._srid = srid
|
|
234
|
+
|
|
232
235
|
|
|
233
236
|
async def delete(self) -> None:
|
|
234
237
|
"""
|
|
@@ -244,7 +247,7 @@ class Feature(AsyncBase):
|
|
|
244
247
|
>>> feature = await layer.get_feature(id=1)
|
|
245
248
|
>>> await feature.delete()
|
|
246
249
|
"""
|
|
247
|
-
await super().
|
|
250
|
+
await super()._delete(self.endpoint)
|
|
248
251
|
|
|
249
252
|
|
|
250
253
|
async def update(self, geojson: Dict) -> Dict:
|
|
@@ -274,7 +277,7 @@ class Feature(AsyncBase):
|
|
|
274
277
|
|
|
275
278
|
|
|
276
279
|
@classmethod
|
|
277
|
-
async def create_feature(cls, layer: 'VectorLayer', geojson: Dict) -> '
|
|
280
|
+
async def create_feature(cls, layer: 'VectorLayer', geojson: Dict) -> 'AsyncFeature':
|
|
278
281
|
"""
|
|
279
282
|
[async] Create a new feature in the vector layer.
|
|
280
283
|
|
|
@@ -283,7 +286,7 @@ class Feature(AsyncBase):
|
|
|
283
286
|
geojson (Dict): The GeoJSON data for the feature
|
|
284
287
|
|
|
285
288
|
Returns:
|
|
286
|
-
|
|
289
|
+
AsyncFeature: The created feature instance
|
|
287
290
|
|
|
288
291
|
Example:
|
|
289
292
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
@@ -297,11 +300,11 @@ class Feature(AsyncBase):
|
|
|
297
300
|
>>> feature = await Feature.create_feature(layer, geojson)
|
|
298
301
|
"""
|
|
299
302
|
endpoint = urljoin(layer.endpoint, 'features/')
|
|
300
|
-
return await cls._create(layer.api, endpoint, geojson, factory_func=lambda api, item:
|
|
303
|
+
return await cls._create(layer.api, endpoint, geojson, factory_func=lambda api, item: AsyncFeature(layer, data=item))
|
|
301
304
|
|
|
302
305
|
|
|
303
306
|
@classmethod
|
|
304
|
-
async def get_feature(cls, layer: 'VectorLayer', feature_id: int, user_id: int = None) -> '
|
|
307
|
+
async def get_feature(cls, layer: 'VectorLayer', feature_id: int, user_id: int = None) -> 'AsyncFeature':
|
|
305
308
|
"""
|
|
306
309
|
[async] Get a feature by its ID.
|
|
307
310
|
|
|
@@ -311,21 +314,21 @@ class Feature(AsyncBase):
|
|
|
311
314
|
user_id (int): specific user. privileges required.
|
|
312
315
|
|
|
313
316
|
Returns:
|
|
314
|
-
|
|
317
|
+
AsyncFeature: The retrieved feature instance
|
|
315
318
|
|
|
316
319
|
Example:
|
|
317
320
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
318
|
-
>>> from geobox.aio.feature import
|
|
321
|
+
>>> from geobox.aio.feature import AsyncFeature
|
|
319
322
|
>>> async with AsyncGeoboxClient() as client:
|
|
320
323
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
321
|
-
>>> feature = await
|
|
324
|
+
>>> feature = await AsyncFeature.get_feature(layer, feature_id=1)
|
|
322
325
|
"""
|
|
323
326
|
param = {
|
|
324
327
|
'f': 'json',
|
|
325
328
|
'user_id': user_id
|
|
326
329
|
}
|
|
327
330
|
endpoint = urljoin(layer.endpoint, f'features/')
|
|
328
|
-
return await cls._get_detail(layer.api, endpoint, uuid=feature_id, params=param, factory_func=lambda api, item:
|
|
331
|
+
return await cls._get_detail(layer.api, endpoint, uuid=feature_id, params=param, factory_func=lambda api, item: AsyncFeature(layer, data=item))
|
|
329
332
|
|
|
330
333
|
|
|
331
334
|
@property
|
|
@@ -344,7 +347,6 @@ class Feature(AsyncBase):
|
|
|
344
347
|
|
|
345
348
|
Example:
|
|
346
349
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
347
|
-
>>> from geobox.aio.feature import Feature
|
|
348
350
|
>>> async with AsyncGeoboxClient() as client:
|
|
349
351
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
350
352
|
>>> feature = await layer.get_feature(id=1)
|
|
@@ -395,7 +397,6 @@ class Feature(AsyncBase):
|
|
|
395
397
|
|
|
396
398
|
Example:
|
|
397
399
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
398
|
-
>>> from geobox.aio.feature import Feature
|
|
399
400
|
>>> from shapely.affinity import translate
|
|
400
401
|
>>> async with AsyncGeoboxClient() as client:
|
|
401
402
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
@@ -423,7 +424,7 @@ class Feature(AsyncBase):
|
|
|
423
424
|
self.data['geometry'] = mapping(value)
|
|
424
425
|
|
|
425
426
|
|
|
426
|
-
def transform(self, out_srid: int) -> '
|
|
427
|
+
def transform(self, out_srid: int) -> 'AsyncFeature':
|
|
427
428
|
"""
|
|
428
429
|
Transform the feature geometry to a new SRID.
|
|
429
430
|
|
|
@@ -431,7 +432,7 @@ class Feature(AsyncBase):
|
|
|
431
432
|
out_srid (int): The target SRID to transform the geometry to (e.g., 4326 for WGS84, 3857 for Web Mercator)
|
|
432
433
|
|
|
433
434
|
Returns:
|
|
434
|
-
|
|
435
|
+
AsyncFeature: A new Feature instance with transformed geometry.
|
|
435
436
|
|
|
436
437
|
Raises:
|
|
437
438
|
ValueError: If the feature has no geometry or if the transformation fails.
|
|
@@ -439,7 +440,6 @@ class Feature(AsyncBase):
|
|
|
439
440
|
|
|
440
441
|
Example:
|
|
441
442
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
442
|
-
>>> from geobox.aio.feature import Feature
|
|
443
443
|
>>> async with AsyncGeoboxClient() as client:
|
|
444
444
|
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
445
445
|
>>> feature = await layer.get_feature(id=1, srid=3857)
|
|
@@ -502,15 +502,15 @@ class Feature(AsyncBase):
|
|
|
502
502
|
return self
|
|
503
503
|
|
|
504
504
|
|
|
505
|
-
def to_sync(self, sync_client: '
|
|
505
|
+
def to_sync(self, sync_client: 'GeoboxClient') -> 'Feature':
|
|
506
506
|
"""
|
|
507
507
|
[async] Switch to sync version of the feature instance to have access to the sync methods
|
|
508
508
|
|
|
509
509
|
Args:
|
|
510
|
-
sync_client (
|
|
510
|
+
sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
511
511
|
|
|
512
512
|
Returns:
|
|
513
|
-
|
|
513
|
+
Feature: the sync instance of the feature.
|
|
514
514
|
|
|
515
515
|
Example:
|
|
516
516
|
>>> from geobox import Geoboxclient
|
|
@@ -521,7 +521,7 @@ class Feature(AsyncBase):
|
|
|
521
521
|
>>> feature = await layer.get_feature(id=1, srid=3857)
|
|
522
522
|
>>> sync_feature = feature.to_sync(client)
|
|
523
523
|
"""
|
|
524
|
-
from ..feature import Feature
|
|
524
|
+
from ..feature import Feature
|
|
525
525
|
|
|
526
526
|
sync_layer = self.layer.to_sync(sync_client=sync_client)
|
|
527
|
-
return
|
|
527
|
+
return Feature(layer=sync_layer, srid=self.srid, data=self.data)
|