geobox 2.2.2__py3-none-any.whl → 2.2.4__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
@@ -219,11 +219,8 @@ class AsyncFeature(AsyncBase):
219
219
 
220
220
  try:
221
221
  if self.id:
222
- if self.srid != self.BASE_SRID:
223
- self = self.transform(self.BASE_SRID)
224
- self.data['geometry'] = self.original_geometry
225
222
  await self.update(self.data)
226
- self.coordinates = data['geometry']['coordinates']
223
+
227
224
  except AttributeError:
228
225
  if self.srid != self.BASE_SRID:
229
226
  self = self.transform(self.BASE_SRID)
@@ -277,7 +274,17 @@ class AsyncFeature(AsyncBase):
277
274
  ... }
278
275
  >>> await feature.update(geojson)
279
276
  """
280
- return await super()._update(self.endpoint, geojson, clean=False)
277
+ self.data = geojson
278
+ data = self.data.copy()
279
+ srid = self.srid
280
+
281
+ if self.srid != self.BASE_SRID:
282
+ self = self.transform(self.BASE_SRID)
283
+
284
+ await super()._update(self.endpoint, self.data, clean=False)
285
+ self.data['geometry'] = data['geometry']
286
+ self._srid = srid
287
+ return self.data
281
288
 
282
289
 
283
290
  @classmethod
geobox/aio/vectorlayer.py CHANGED
@@ -658,10 +658,14 @@ class AsyncVectorLayer(AsyncBase):
658
658
  return response
659
659
 
660
660
 
661
- async def get_features(self, **kwargs) -> Union[List['AsyncFeature'], int]:
661
+ async def get_features(self, geojson: bool = False, **kwargs) -> Union[List['AsyncFeature'], Dict, int]:
662
662
  """
663
663
  [async] Get features from the layer with optional filtering and pagination.
664
664
 
665
+ Args:
666
+ geojson (bool, optional): If True, returns the raw API response (GeoJSON dict).
667
+ If False, returns a list of Feature objects. default: False.
668
+
665
669
  Keyword Args:
666
670
  quant_factor (int): Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. default is 1000000.
667
671
  skip (int): Number of features to skip. default is 0.
@@ -681,7 +685,7 @@ class AsyncVectorLayer(AsyncBase):
681
685
  bbox_srid (int): srid (epsg code) of bbox. e.g. 4326. default is 3857.
682
686
 
683
687
  Returns:
684
- List[Feature] | int: A list of Feature instances or the features count if return_count is True.
688
+ List[Feature] | Dict | int: A list of Feature instances or the geojson api response if geojson=True or the features count if return_count is True.
685
689
 
686
690
  Example:
687
691
  >>> from geobox.aio import AsyncGeoboxClient
@@ -718,8 +722,13 @@ class AsyncVectorLayer(AsyncBase):
718
722
  'bbox_srid': kwargs.get('bbox_srid', 3857)
719
723
  }
720
724
 
725
+ endpoint = f'{self.endpoint}features/'
726
+
727
+ if geojson:
728
+ return await self.api.get(endpoint)
729
+
721
730
  return await super()._get_list(api=self.api,
722
- endpoint=f'{self.endpoint}features/',
731
+ endpoint=endpoint,
723
732
  params=params,
724
733
  factory_func=lambda api, item, srid: AsyncFeature(self, srid, item),
725
734
  geojson=True)
geobox/aio/view.py CHANGED
@@ -451,10 +451,14 @@ class AsyncVectorLayerView(AsyncVectorLayer):
451
451
  return await super().calculate_field(target_field, expression, q, bbox, bbox_srid, feature_ids, run_async, user_id)
452
452
 
453
453
 
454
- async def get_features(self, **kwargs) -> Union[List['AsyncFeature'], int]:
454
+ async def get_features(self, geojson: bool = False, **kwargs) -> Union[List['AsyncFeature'], Dict, int]:
455
455
  """
456
456
  [async] Get features from the layer with optional filtering and pagination.
457
457
 
458
+ Args:
459
+ geojson (bool, optional): If True, returns the raw API response (GeoJSON dict).
460
+ If False, returns a list of Feature objects. default: False.
461
+
458
462
  Keyword Args:
459
463
  quant_factor (int): Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. default is 1000000.
460
464
  skip (int): Number of features to skip. default is 0.
@@ -474,7 +478,7 @@ class AsyncVectorLayerView(AsyncVectorLayer):
474
478
  bbox_srid (int): srid (epsg code) of bbox. e.g. 4326. default is 3857.
475
479
 
476
480
  Returns:
477
- List[AsyncFeature] | int: A list of Feature instances or the features count if return_count is True.
481
+ List[Feature] | Dict | int: A list of Feature instances or the geojson api response if geojson=True or the features count if return_count is True.
478
482
 
479
483
 
480
484
  Example:
@@ -491,7 +495,7 @@ class AsyncVectorLayerView(AsyncVectorLayer):
491
495
  ... out_srid=4326,
492
496
  ... bbox_srid=4326)
493
497
  """
494
- return await super().get_features(**kwargs)
498
+ return await super().get_features(geojson=geojson, **kwargs)
495
499
 
496
500
 
497
501
  async def get_feature(self, feature_id: int, out_srid: int = AsyncFeature.BASE_SRID) -> 'AsyncFeature':
geobox/feature.py CHANGED
@@ -236,11 +236,8 @@ class Feature(Base):
236
236
 
237
237
  try:
238
238
  if self.id:
239
- if self.srid != self.BASE_SRID:
240
- self = self.transform(self.BASE_SRID)
241
- self.data['geometry'] = self.original_geometry
242
239
  self.update(self.data)
243
- self.coordinates = data['geometry']['coordinates']
240
+
244
241
  except AttributeError:
245
242
  if self.srid != self.BASE_SRID:
246
243
  self = self.transform(self.BASE_SRID)
@@ -295,7 +292,17 @@ class Feature(Base):
295
292
  ... }
296
293
  >>> feature.update(geojson)
297
294
  """
298
- return super()._update(self.endpoint, geojson, clean=False)
295
+ self.data = geojson
296
+ data = self.data.copy()
297
+ srid = self.srid
298
+
299
+ if self.srid != self.BASE_SRID:
300
+ self = self.transform(self.BASE_SRID)
301
+
302
+ super()._update(self.endpoint, self.data, clean=False)
303
+ self.data['geometry'] = data['geometry']
304
+ self._srid = srid
305
+ return self.data
299
306
 
300
307
 
301
308
  @classmethod
geobox/vectorlayer.py CHANGED
@@ -660,10 +660,14 @@ class VectorLayer(Base):
660
660
  return response
661
661
 
662
662
 
663
- def get_features(self, **kwargs) -> Union[List['Feature'], int]:
663
+ def get_features(self, geojson: bool = False, **kwargs) -> Union[List['Feature'], Dict, int]:
664
664
  """
665
665
  Get features from the layer with optional filtering and pagination.
666
666
 
667
+ Args:
668
+ geojson (bool, optional): If True, returns the raw API response (GeoJSON dict).
669
+ If False, returns a list of Feature objects. default: False.
670
+
667
671
  Keyword Args:
668
672
  quant_factor (int): Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. default is 1000000.
669
673
  skip (int): Number of features to skip. default is 0.
@@ -683,7 +687,7 @@ class VectorLayer(Base):
683
687
  bbox_srid (int): srid (epsg code) of bbox. e.g. 4326. default is 3857.
684
688
 
685
689
  Returns:
686
- List[Feature] | int: A list of Feature instances or the features count if return_count is True.
690
+ List[Feature] | Dict | int: A list of Feature instances or the geojson api response if geojson=True or the features count if return_count is True.
687
691
 
688
692
  Example:
689
693
  >>> from geobox import GeoboxClient
@@ -691,13 +695,13 @@ class VectorLayer(Base):
691
695
  >>> client = GeoboxClient()
692
696
  >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
693
697
  >>> features = layer.get_features(quant_factor=1000000,
694
- ... skip=0,
695
- ... limit=100,
696
- ... skip_geometry=False,
697
- ... return_count=False,
698
- ... select_fields="fclass, osm_id",
699
- ... out_srid=3857,
700
- ... bbox_srid=3857)
698
+ ... skip=0,
699
+ ... limit=100,
700
+ ... skip_geometry=False,
701
+ ... return_count=False,
702
+ ... select_fields="fclass, osm_id",
703
+ ... out_srid=3857,
704
+ ... bbox_srid=3857)
701
705
  """
702
706
  params = {
703
707
  'f': 'json',
@@ -719,11 +723,16 @@ class VectorLayer(Base):
719
723
  'bbox_srid': kwargs.get('bbox_srid', 3857)
720
724
  }
721
725
 
726
+ endpoint = f'{self.endpoint}features/'
727
+
728
+ if geojson:
729
+ return self.api.get(endpoint)
730
+
722
731
  return super()._get_list(api=self.api,
723
- endpoint=f'{self.endpoint}features/',
724
- params=params,
725
- factory_func=lambda api, item, srid: Feature(self, srid, item),
726
- geojson=True)
732
+ endpoint=endpoint,
733
+ params=params,
734
+ factory_func=lambda api, item, srid: Feature(self, srid, item),
735
+ geojson=True)
727
736
 
728
737
 
729
738
  def get_feature(self, feature_id: int, out_srid: int = Feature.BASE_SRID) -> 'Feature':
geobox/view.py CHANGED
@@ -445,10 +445,14 @@ class VectorLayerView(VectorLayer):
445
445
  return super().calculate_field(target_field, expression, q, bbox, bbox_srid, feature_ids, run_async, user_id)
446
446
 
447
447
 
448
- def get_features(self, **kwargs) -> Union[List['Feature'], int]:
448
+ def get_features(self, geojson: bool = False, **kwargs) -> Union[List['Feature'], Dict, int]:
449
449
  """
450
450
  Get features from the layer with optional filtering and pagination.
451
451
 
452
+ Args:
453
+ geojson (bool, optional): If True, returns the raw API response (GeoJSON dict).
454
+ If False, returns a list of Feature objects. default: False.
455
+
452
456
  Keyword Args:
453
457
  quant_factor (int): Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. default is 1000000.
454
458
  skip (int): Number of features to skip. default is 0.
@@ -468,7 +472,7 @@ class VectorLayerView(VectorLayer):
468
472
  bbox_srid (int): srid (epsg code) of bbox. e.g. 4326. default is 3857.
469
473
 
470
474
  Returns:
471
- List[Feature] | int: A list of Feature instances or the features count if return_count is True.
475
+ List[Feature] | Dict | int: A list of Feature instances or the geojson api response if geojson=True or the features count if return_count is True.
472
476
 
473
477
 
474
478
  Example:
@@ -477,15 +481,15 @@ class VectorLayerView(VectorLayer):
477
481
  >>> client = GeoboxClient()
478
482
  >>> layer = VectorLayerView(api=client, name="my_layer", layer_type=LayerType.Point)
479
483
  >>> features = layer.get_features(quant_factor=1000000,
480
- ... skip=0,
481
- ... limit=100,
482
- ... skip_geometry=False,
483
- ... return_count=False,
484
- ... select_fields="fclass, osm_id",
485
- ... out_srid=4326,
486
- ... bbox_srid=4326)
487
- """
488
- return super().get_features(**kwargs)
484
+ ... skip=0,
485
+ ... limit=100,
486
+ ... skip_geometry=False,
487
+ ... return_count=False,
488
+ ... select_fields="fclass, osm_id",
489
+ ... out_srid=4326,
490
+ ... bbox_srid=4326)
491
+ """
492
+ return super().get_features(geojson=geojson, **kwargs)
489
493
 
490
494
 
491
495
  def get_feature(self, feature_id: int, out_srid: int = Feature.BASE_SRID) -> 'Feature':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 2.2.2
3
+ Version: 2.2.4
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=pcw-c8M-ZCOyrZP0GgaXqtX6KVd330P7HcxKgJVVW3g,20402
10
+ geobox/feature.py,sha256=YP-wCSxEin93ji6Hq72LG7j1VjGC0Jk05g06IOW_W8I,20455
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
@@ -29,9 +29,9 @@ 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=QYa_-eBk9WdMYUdGeC8MaqsYm1P6tk5J2tgejrzgv_g,58701
32
+ geobox/vectorlayer.py,sha256=R4EFFrfJkGbIj63VnqKE2YW1Io-FqGET2lb6DEv1N5I,58803
33
33
  geobox/version.py,sha256=KcPCSe9vD6rc11qaTVO8UxYwXRX-0r0tQVaF-CJPfB0,10797
34
- geobox/view.py,sha256=DJL1wdccZC_ZR6V5hYDYDFZCC9lqle4wheaIOxOa__I,43266
34
+ geobox/view.py,sha256=GLC2ZA7SN_I8bP8KkZjUKYDZHw9RMg00Y7x7LQNyEJY,43361
35
35
  geobox/workflow.py,sha256=SWq4y6J4-6GwYn8uKWTAdYj0rX6romF_s20C0Cth8d0,12931
36
36
  geobox/aio/__init__.py,sha256=4Ufsv-VOW7FQGD1OmSRKH7E3sLCaKC0MpEMsSMBC3ro,1933
37
37
  geobox/aio/api.py,sha256=am3Yl77WWBVibSOuid4vh-L6vca_Y4q4Ff_0Fgd-t0I,110041
@@ -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=xwIiBR4lTXqjxs6UpoYh3kJoP46Rp_8FN_roZ5x_7Mg,20486
43
+ geobox/aio/feature.py,sha256=BouLyHGqpHsxMkSEs5EEPwzyzDdkzqnxlWZ7td1b-tY,20523
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
@@ -61,12 +61,12 @@ 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=d7BAPjp1MsFWhrgDh3gJ8LBAIA_2-vCGCT0ji9-e1O4,59426
64
+ geobox/aio/vectorlayer.py,sha256=qucLKg76sVSZt6WxU9PL5C6ROJ4uxdxSBXm5dUfIsBA,59801
65
65
  geobox/aio/version.py,sha256=Yt7tKUqHS8rKfTPAm77yAaDajFn0ZEo0UWhA5DN7_uM,11422
66
- geobox/aio/view.py,sha256=CMULdkierGeIvRWdyfqy6FO_9_fgQeSAA1-xdcrl9Uw,45146
66
+ geobox/aio/view.py,sha256=u6TpBsd5PzqCLv6XRJtReeB68C7mxS-WqqDt2BDtxPs,45439
67
67
  geobox/aio/workflow.py,sha256=UwOVMDRjJIiveXbYB8rGO02s5A7fn2BhEvQXkWMSApU,13707
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,,
68
+ geobox-2.2.4.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
69
+ geobox-2.2.4.dist-info/METADATA,sha256=ahdZI2Yls6TXeQaGgFtvc3A24CK5jDlBTqumE-Guxa8,3082
70
+ geobox-2.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
71
+ geobox-2.2.4.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
72
+ geobox-2.2.4.dist-info/RECORD,,
File without changes