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.
Files changed (70) hide show
  1. geobox/__init__.py +61 -63
  2. geobox/aio/__init__.py +61 -63
  3. geobox/aio/api.py +491 -574
  4. geobox/aio/apikey.py +263 -263
  5. geobox/aio/attachment.py +341 -339
  6. geobox/aio/base.py +261 -262
  7. geobox/aio/basemap.py +196 -196
  8. geobox/aio/dashboard.py +340 -342
  9. geobox/aio/feature.py +35 -35
  10. geobox/aio/field.py +315 -321
  11. geobox/aio/file.py +72 -72
  12. geobox/aio/layout.py +340 -341
  13. geobox/aio/log.py +23 -23
  14. geobox/aio/map.py +1033 -1034
  15. geobox/aio/model3d.py +415 -415
  16. geobox/aio/mosaic.py +696 -696
  17. geobox/aio/plan.py +314 -314
  18. geobox/aio/query.py +693 -693
  19. geobox/aio/raster.py +88 -454
  20. geobox/aio/{analysis.py → raster_analysis.py} +153 -170
  21. geobox/aio/route.py +4 -4
  22. geobox/aio/scene.py +340 -342
  23. geobox/aio/settings.py +18 -18
  24. geobox/aio/task.py +404 -402
  25. geobox/aio/tile3d.py +337 -339
  26. geobox/aio/tileset.py +102 -103
  27. geobox/aio/usage.py +52 -51
  28. geobox/aio/user.py +506 -507
  29. geobox/aio/vector_tool.py +1968 -0
  30. geobox/aio/vectorlayer.py +316 -414
  31. geobox/aio/version.py +272 -273
  32. geobox/aio/view.py +1019 -983
  33. geobox/aio/workflow.py +340 -341
  34. geobox/api.py +14 -98
  35. geobox/apikey.py +262 -262
  36. geobox/attachment.py +336 -337
  37. geobox/base.py +384 -384
  38. geobox/basemap.py +194 -194
  39. geobox/dashboard.py +339 -341
  40. geobox/enums.py +31 -1
  41. geobox/feature.py +31 -10
  42. geobox/field.py +320 -320
  43. geobox/file.py +4 -4
  44. geobox/layout.py +339 -340
  45. geobox/log.py +4 -4
  46. geobox/map.py +1031 -1032
  47. geobox/model3d.py +410 -410
  48. geobox/mosaic.py +696 -696
  49. geobox/plan.py +313 -313
  50. geobox/query.py +691 -691
  51. geobox/raster.py +5 -368
  52. geobox/{analysis.py → raster_analysis.py} +108 -128
  53. geobox/scene.py +341 -342
  54. geobox/settings.py +194 -194
  55. geobox/task.py +399 -400
  56. geobox/tile3d.py +337 -338
  57. geobox/tileset.py +4 -4
  58. geobox/usage.py +3 -3
  59. geobox/user.py +503 -503
  60. geobox/vector_tool.py +1968 -0
  61. geobox/vectorlayer.py +5 -110
  62. geobox/version.py +272 -272
  63. geobox/view.py +981 -981
  64. geobox/workflow.py +338 -339
  65. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/METADATA +15 -1
  66. geobox-2.2.1.dist-info/RECORD +72 -0
  67. geobox-2.1.0.dist-info/RECORD +0 -70
  68. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/WHEEL +0 -0
  69. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/licenses/LICENSE +0 -0
  70. {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 as SyncGeoboxClient
10
- from ..feature import Feature as SyncFeature
9
+ from ..api import GeoboxClient
10
+ from ..feature import Feature
11
11
 
12
12
 
13
- class Feature(AsyncBase):
13
+ class AsyncFeature(AsyncBase):
14
14
 
15
15
  BASE_SRID = 3857
16
16
 
17
17
  def __init__(self,
18
- layer: 'VectorLayer',
19
- srid: Optional[int] = 3857,
20
- data: Optional[Dict] = {}):
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
- return f"Feature(id={self.id}, type={self.feature_type})"
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.data['geometry'] = self.original_geometry
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
- response = await self.layer.api.post(endpoint, data)
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().delete(self.endpoint)
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) -> 'Feature':
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
- Feature: The created feature instance
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: Feature(layer, data=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) -> 'Feature':
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
- Feature: The retrieved feature instance
317
+ AsyncFeature: The retrieved feature instance
315
318
 
316
319
  Example:
317
320
  >>> from geobox.aio import AsyncGeoboxClient
318
- >>> from geobox.aio.feature import Feature
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 Feature.get_feature(layer, feature_id=1)
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: Feature(layer, data=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) -> 'Feature':
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
- Feature: A new Feature instance with transformed geometry.
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: 'SyncGeoboxClient') -> 'SyncFeature':
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 (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
510
+ sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
511
511
 
512
512
  Returns:
513
- geobox.feature.Feature: the sync instance of the feature.
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 as SyncFeature
524
+ from ..feature import Feature
525
525
 
526
526
  sync_layer = self.layer.to_sync(sync_client=sync_client)
527
- return SyncFeature(layer=sync_layer, srid=self.srid, data=self.data)
527
+ return Feature(layer=sync_layer, srid=self.srid, data=self.data)