geobox 2.2.1__py3-none-any.whl → 2.2.2__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/aio/feature.py CHANGED
@@ -29,7 +29,11 @@ class AsyncFeature(AsyncBase):
29
29
  super().__init__(api=layer.api)
30
30
  self.layer = layer
31
31
  self._srid = srid
32
- self.data = data or {}
32
+ self.data = data or {
33
+ "type": "Feature",
34
+ "geometry": {},
35
+ "properties": {}
36
+ }
33
37
  self.original_geometry = self.data.get('geometry')
34
38
  self.endpoint = urljoin(layer.endpoint, f'features/{self.data.get("id")}/') if self.data.get('id') else None
35
39
 
@@ -277,13 +281,14 @@ class AsyncFeature(AsyncBase):
277
281
 
278
282
 
279
283
  @classmethod
280
- async def create_feature(cls, layer: 'VectorLayer', geojson: Dict) -> 'AsyncFeature':
284
+ async def create_feature(cls, layer: 'VectorLayer', geojson: Dict, srid: int = 3857) -> 'AsyncFeature':
281
285
  """
282
286
  [async] Create a new feature in the vector layer.
283
287
 
284
288
  Args:
285
289
  layer (VectorLayer): The vector layer to create the feature in
286
290
  geojson (Dict): The GeoJSON data for the feature
291
+ srid (int, optional): the feature srid. default: 3857
287
292
 
288
293
  Returns:
289
294
  AsyncFeature: The created feature instance
@@ -299,8 +304,19 @@ class AsyncFeature(AsyncBase):
299
304
  ... }
300
305
  >>> feature = await Feature.create_feature(layer, geojson)
301
306
  """
307
+ feature = AsyncFeature(layer, srid=srid, data=geojson)
308
+ data = feature.data.copy()
309
+ srid = feature.srid
310
+
311
+ if feature.srid != feature.BASE_SRID:
312
+ feature = feature.transform(feature.BASE_SRID)
313
+
302
314
  endpoint = urljoin(layer.endpoint, 'features/')
303
- return await cls._create(layer.api, endpoint, geojson, factory_func=lambda api, item: AsyncFeature(layer, data=item))
315
+
316
+ feature = await cls._create(layer.api, endpoint, feature.data, factory_func=lambda api, item: AsyncFeature(layer, data=item))
317
+ feature.data['geometry'] = data['geometry']
318
+ feature._srid = srid
319
+ return feature
304
320
 
305
321
 
306
322
  @classmethod
@@ -360,10 +376,7 @@ class AsyncFeature(AsyncBase):
360
376
  "Install it with: pip install geobox[geometry]"
361
377
  )
362
378
 
363
- if not self.data:
364
- return None
365
-
366
- elif not self.data.get('geometry'):
379
+ if not self.data.get('geometry'):
367
380
  raise ValueError("Geometry is not present in the feature data")
368
381
 
369
382
  elif not isinstance(self.data['geometry'], dict):
geobox/aio/task.py CHANGED
@@ -2,6 +2,7 @@ import time
2
2
  import asyncio
3
3
  from urllib.parse import urljoin
4
4
  from typing import Optional, Dict, List, Optional, Union, TYPE_CHECKING
5
+ import logging
5
6
 
6
7
  from .base import AsyncBase
7
8
  from ..enums import TaskStatus
@@ -16,6 +17,8 @@ if TYPE_CHECKING:
16
17
  from ..api import GeoboxClient
17
18
  from ..task import Task
18
19
 
20
+ logger = logging.getLogger(__name__)
21
+
19
22
 
20
23
  class AsyncTask(AsyncBase):
21
24
 
@@ -233,7 +236,7 @@ class AsyncTask(AsyncBase):
233
236
  return await self._wait(timeout, interval, progress_bar)
234
237
  except Exception as e:
235
238
  last_exception = e
236
- print(f"[Retry {attempt}/{retry}] Task wait failed: {e}")
239
+ logger.warning(f"[Retry {attempt}/{retry}] Task wait failed: {e}")
237
240
  time.sleep(interval)
238
241
  raise last_exception
239
242
 
geobox/aio/vectorlayer.py CHANGED
@@ -755,12 +755,13 @@ class AsyncVectorLayer(AsyncBase):
755
755
  return feature
756
756
 
757
757
 
758
- async def create_feature(self, geojson: Dict)-> 'AsyncFeature':
758
+ async def create_feature(self, geojson: Dict, srid: int = AsyncFeature.BASE_SRID)-> 'AsyncFeature':
759
759
  """
760
760
  [async] Create a new feature in the layer.
761
761
 
762
762
  Args:
763
763
  geojson (Dict): The feature data including properties and geometry.
764
+ srid (int, optional): the feature srid. default: 3857
764
765
 
765
766
  Returns:
766
767
  Feature: The newly created feature instance.
@@ -780,7 +781,7 @@ class AsyncVectorLayer(AsyncBase):
780
781
  ... }
781
782
  >>> feature = await layer.create_feature(geojson=geojson)
782
783
  """
783
- return await AsyncFeature.create_feature(self, geojson)
784
+ return await AsyncFeature.create_feature(self, geojson, srid=srid)
784
785
 
785
786
 
786
787
  async def delete_features(self,
geobox/feature.py CHANGED
@@ -34,7 +34,7 @@ class Feature(Base):
34
34
  ... "type": "Feature",
35
35
  ... "geometry": {
36
36
  ... "type": "Point",
37
- ... "coordinates": [58.4, 23.6]
37
+ ... "coordinates": [10.0, 10.0]
38
38
  ... },
39
39
  ... "properties": {
40
40
  ... "name": "Test feature"
@@ -46,7 +46,11 @@ class Feature(Base):
46
46
  super().__init__(api=layer.api)
47
47
  self.layer = layer
48
48
  self._srid = srid
49
- self.data = data or {}
49
+ self.data = data or {
50
+ "type": "Feature",
51
+ "geometry": {},
52
+ "properties": {}
53
+ }
50
54
  self.original_geometry = self.data.get('geometry')
51
55
  self.endpoint = urljoin(layer.endpoint, f'features/{self.data.get("id")}/') if self.data.get('id') else None
52
56
 
@@ -295,13 +299,14 @@ class Feature(Base):
295
299
 
296
300
 
297
301
  @classmethod
298
- def create_feature(cls, layer: 'VectorLayer', geojson: Dict) -> 'Feature':
302
+ def create_feature(cls, layer: 'VectorLayer', geojson: Dict, srid: int = 3857) -> 'Feature':
299
303
  """
300
304
  Create a new feature in the vector layer.
301
305
 
302
306
  Args:
303
307
  layer (VectorLayer): The vector layer to create the feature in
304
308
  geojson (Dict): The GeoJSON data for the feature
309
+ srid (int, optional): the feature srid. default: 3857
305
310
 
306
311
  Returns:
307
312
  Feature: The created feature instance
@@ -318,8 +323,19 @@ class Feature(Base):
318
323
  ... }
319
324
  >>> feature = Feature.create_feature(layer, geojson)
320
325
  """
326
+ feature = Feature(layer, srid=srid, data=geojson)
327
+ data = feature.data.copy()
328
+ srid = feature.srid
329
+
330
+ if feature.srid != feature.BASE_SRID:
331
+ feature = feature.transform(feature.BASE_SRID)
332
+
321
333
  endpoint = urljoin(layer.endpoint, 'features/')
322
- return cls._create(layer.api, endpoint, geojson, factory_func=lambda api, item: Feature(layer, data=item))
334
+
335
+ feature = cls._create(layer.api, endpoint, feature.data, factory_func=lambda api, item: Feature(layer, data=item))
336
+ feature.data['geometry'] = data['geometry']
337
+ feature._srid = srid
338
+ return feature
323
339
 
324
340
 
325
341
  @classmethod
@@ -380,10 +396,8 @@ class Feature(Base):
380
396
  "Install it with: pip install geobox[geometry]"
381
397
  )
382
398
 
383
- if not self.data:
384
- return None
385
399
 
386
- elif not self.data.get('geometry'):
400
+ if not self.data.get('geometry'):
387
401
  raise ValueError("Geometry is not present in the feature data")
388
402
 
389
403
  elif not isinstance(self.data['geometry'], dict):
geobox/task.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from urllib.parse import urljoin, urlencode
2
2
  from typing import Optional, Dict, List, Optional, Union, TYPE_CHECKING
3
3
  import time
4
+ import logging
4
5
 
5
6
  from .base import Base
6
7
  from .enums import TaskStatus
@@ -15,6 +16,8 @@ if TYPE_CHECKING:
15
16
  from .aio import AsyncGeoboxClient
16
17
  from .aio.task import AsyncTask
17
18
 
19
+ logger = logging.getLogger(__name__)
20
+
18
21
 
19
22
  class Task(Base):
20
23
 
@@ -230,7 +233,7 @@ class Task(Base):
230
233
  return self._wait(timeout, interval, progress_bar)
231
234
  except Exception as e:
232
235
  last_exception = e
233
- print(f"[Retry {attempt}/{retry}] Task wait failed: {e}")
236
+ logger.warning(f"[Retry {attempt}/{retry}] Task wait failed: {e}")
234
237
  time.sleep(interval)
235
238
  raise last_exception
236
239
 
geobox/vectorlayer.py CHANGED
@@ -756,12 +756,13 @@ class VectorLayer(Base):
756
756
  return feature
757
757
 
758
758
 
759
- def create_feature(self, geojson: Dict)-> 'Feature':
759
+ def create_feature(self, geojson: Dict, srid: int = Feature.BASE_SRID)-> 'Feature':
760
760
  """
761
761
  Create a new feature in the layer.
762
762
 
763
763
  Args:
764
764
  geojson (Dict): The feature data including properties and geometry.
765
+ srid (int, optional): the feature srid. default: 3857
765
766
 
766
767
  Returns:
767
768
  Feature: The newly created feature instance.
@@ -781,7 +782,7 @@ class VectorLayer(Base):
781
782
  ... }
782
783
  >>> feature = layer.create_feature(geojson=geojson)
783
784
  """
784
- return Feature.create_feature(self, geojson)
785
+ return Feature.create_feature(self, geojson, srid=srid)
785
786
 
786
787
 
787
788
  def delete_features(self, q: str = None, bbox: str = None, bbox_srid: int = None, feature_ids: List[int] = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: SDK for Geobox's APIs
5
5
  Author-email: Hamid Heydari <heydari.h62@gmail.com>
6
6
  License: MIT
@@ -7,7 +7,7 @@ geobox/basemap.py,sha256=BSDb7mJm-Pmm5GRqvsHxKiqBNL_wfzy_GVv1qqTVFLc,5746
7
7
  geobox/dashboard.py,sha256=Gkt66_WqJEco2olFfZ7W8ux3IhhbbudVqfLlB3t8MCs,13039
8
8
  geobox/enums.py,sha256=jA5KwOdTMkFhXEBgcP-8bgi0cFyD1NFN4QpLelow0HA,8044
9
9
  geobox/exception.py,sha256=jvpnv0M2Ck1FpxHTL_aKYWxGvLnCQ3d9vOrMIktjw1U,1507
10
- geobox/feature.py,sha256=63AaEUkCnT9kbiEIh7LUqnuy2Op0qUPN_oQik0tjfFY,19924
10
+ geobox/feature.py,sha256=pcw-c8M-ZCOyrZP0GgaXqtX6KVd330P7HcxKgJVVW3g,20402
11
11
  geobox/field.py,sha256=_5CS3kj3P-BKCbtAUd7dtkPBnN0D0H1ZKPlKx8DValw,11188
12
12
  geobox/file.py,sha256=cPj3cYjK85BqWIROfA-c1B-yw6d7Gu5ZzyCmFqAJSVY,20191
13
13
  geobox/layout.py,sha256=qnmFYFeVK-_mMjbzPJHAh9DcoMAdz-tzLDoHMpHST-Q,12608
@@ -22,14 +22,14 @@ geobox/raster_analysis.py,sha256=yoWA5_-GixyAJMpo8cHmZcYrEYUvwo2395BwrGlUBaA,349
22
22
  geobox/route.py,sha256=cKZTTHBHM8woWbhHIpCvrRX_doJcTkGktouee0z7oG0,2723
23
23
  geobox/scene.py,sha256=NEeXfOJGj8o7zIMZQjgLGf0FSzba-UMd3P-7KfkGwTs,12621
24
24
  geobox/settings.py,sha256=rYxBdiDUtQTuca5e12j6jyQYafW7gDUeb1U9ES-sk64,6999
25
- geobox/task.py,sha256=Fn2YqyWd9DeZVR92SJO4OQzmz1PfEegA7_VyJ1jgyws,14870
25
+ geobox/task.py,sha256=X78BA90F4Q1yfMdxNYBKXWfwk5O3m_p6clhEiJPEiHA,14935
26
26
  geobox/tile3d.py,sha256=mMRwwpWmHoCyR4UFKrRnM-xLPacmLrPASYhphP0W8u8,12351
27
27
  geobox/tileset.py,sha256=p6fmOyAunwfWKhmjSgWGc060jM2MVfrnQGC_qoE_AIw,25006
28
28
  geobox/usage.py,sha256=nnFq95fB4jdR8Uo0T09izejrrv14jpqoqbvQ8nixajg,9185
29
29
  geobox/user.py,sha256=1tbIfBRko56kHk3BKp3-Jjqm61xlqcmKZq6aKqbxNAY,17953
30
30
  geobox/utils.py,sha256=JmlRqDVIo0vBikzH1XakRrCrEIfLA7_eTJnBWBvGhJI,2243
31
31
  geobox/vector_tool.py,sha256=q6bKhuUI6Zy6DVJU7s5OnooGlfdCRa1EPHnaLXfjeZo,86273
32
- geobox/vectorlayer.py,sha256=OaCWg8n1dvlzNIJ_c98WFU2BEGQBRW_AJxJt4bNxz_8,58593
32
+ geobox/vectorlayer.py,sha256=QYa_-eBk9WdMYUdGeC8MaqsYm1P6tk5J2tgejrzgv_g,58701
33
33
  geobox/version.py,sha256=KcPCSe9vD6rc11qaTVO8UxYwXRX-0r0tQVaF-CJPfB0,10797
34
34
  geobox/view.py,sha256=DJL1wdccZC_ZR6V5hYDYDFZCC9lqle4wheaIOxOa__I,43266
35
35
  geobox/workflow.py,sha256=SWq4y6J4-6GwYn8uKWTAdYj0rX6romF_s20C0Cth8d0,12931
@@ -40,7 +40,7 @@ geobox/aio/attachment.py,sha256=4IzC8Vnt_LJHSzhfhyMtGqrv1AHibkLWO-mOCCtRyO8,1336
40
40
  geobox/aio/base.py,sha256=H9CB-5Gas3c1Xp14nW-PS-syoGNBpyRLN2iujlSxWLU,9455
41
41
  geobox/aio/basemap.py,sha256=7NeEihNGjVZgc6TRfM2w_3RuAGNXRRpEFItmMlR4e4A,6092
42
42
  geobox/aio/dashboard.py,sha256=L91YkVHtcb9QMozoIBOjiobskDM1NfxasVcTZs6hV3U,13843
43
- geobox/aio/feature.py,sha256=6YYZvKXccJ2chnhsyhOIrSCn3aaGEiVgvHRgslKEJ9Y,20012
43
+ geobox/aio/feature.py,sha256=xwIiBR4lTXqjxs6UpoYh3kJoP46Rp_8FN_roZ5x_7Mg,20486
44
44
  geobox/aio/field.py,sha256=KTN6P1edmPj7NlLEyUHx2BW6dY0TLPdHjCefB6_4L5g,11512
45
45
  geobox/aio/file.py,sha256=RaygwYB4fkmxQyIG__NZZCdnXc7olOY2UC9qGQ3UhkQ,21217
46
46
  geobox/aio/layout.py,sha256=IasLEPVq5U_9VbTPPo-JqxKL4rPxWrVFoHbRdQZk9iY,13471
@@ -55,18 +55,18 @@ geobox/aio/raster_analysis.py,sha256=aSU_E8TXrex2x9w3S4WCWGTu0q81qOBN0rXo5uG5IgM
55
55
  geobox/aio/route.py,sha256=dkKsK4ZjL7XikgoZ3lJfkr2UXwrmxct4Qt2DzZg0upE,2860
56
56
  geobox/aio/scene.py,sha256=28R3cig3HZPPEhcOlb6_WQ210hxPIYgVg14ae8tnCPg,13402
57
57
  geobox/aio/settings.py,sha256=w3QcncZ2OposVHQeQKYOTowj-zFAWuEHN-2ZMzKOe14,7009
58
- geobox/aio/task.py,sha256=aE1OjhZOAl_xAy3OVhXan-wxWc1-wVEbyJ7UeFQF_2c,15868
58
+ geobox/aio/task.py,sha256=ghw_1RU7QkGI2XEwQhz2WRZ6DWqdmwa0yTFx-CBeOAE,15933
59
59
  geobox/aio/tile3d.py,sha256=bN7IqmNzIfW0ofZUh49FjnakV2tuPUQnQgiA83zqrmE,13266
60
60
  geobox/aio/tileset.py,sha256=t2pcC2NmS1uVrpJqci9XUuSKEuq4v05fW2AS5QBTK3w,27639
61
61
  geobox/aio/usage.py,sha256=_I153m0uza7ZooMdHInBVmTt14SCu1qmvvmr80zmVLM,9506
62
62
  geobox/aio/user.py,sha256=-7DJW-mi6_wrJFIfL3oto7YqNoLTg7fLAZEFn9yiAhQ,19056
63
63
  geobox/aio/vector_tool.py,sha256=_6sFu7WllK82M7E6zl0Tteb7at05OsgMnWUEDlD41sk,92886
64
- geobox/aio/vectorlayer.py,sha256=flA3MQFD1Qm6TohftcTXfDQ5VGZztHr1K3zhZZ0x2og,59313
64
+ geobox/aio/vectorlayer.py,sha256=d7BAPjp1MsFWhrgDh3gJ8LBAIA_2-vCGCT0ji9-e1O4,59426
65
65
  geobox/aio/version.py,sha256=Yt7tKUqHS8rKfTPAm77yAaDajFn0ZEo0UWhA5DN7_uM,11422
66
66
  geobox/aio/view.py,sha256=CMULdkierGeIvRWdyfqy6FO_9_fgQeSAA1-xdcrl9Uw,45146
67
67
  geobox/aio/workflow.py,sha256=UwOVMDRjJIiveXbYB8rGO02s5A7fn2BhEvQXkWMSApU,13707
68
- geobox-2.2.1.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
69
- geobox-2.2.1.dist-info/METADATA,sha256=_XDz9bfQYs0hAhFYWLxfCsemT183cW5YBPVPcZ_wbZo,3082
70
- geobox-2.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
71
- geobox-2.2.1.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
72
- geobox-2.2.1.dist-info/RECORD,,
68
+ geobox-2.2.2.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
69
+ geobox-2.2.2.dist-info/METADATA,sha256=rrquHcWpx-9s73j6JOQtkmpdFJpYT7nihZGUxsqJHkk,3082
70
+ geobox-2.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
71
+ geobox-2.2.2.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
72
+ geobox-2.2.2.dist-info/RECORD,,
File without changes