geobox 2.2.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/aio/feature.py CHANGED
@@ -58,7 +58,8 @@ class AsyncFeature(AsyncBase):
58
58
  Returns:
59
59
  str: A string representation of the Feature object.
60
60
  """
61
- return f"AsyncFeature(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})"
62
63
 
63
64
 
64
65
  def __getattr__(self, name: str) -> Any:
@@ -210,18 +211,27 @@ class AsyncFeature(AsyncBase):
210
211
  >>> await feature.save()
211
212
  """
212
213
  data = self.data.copy()
214
+ srid = self.srid
215
+
213
216
  try:
214
217
  if self.id:
215
218
  if self.srid != self.BASE_SRID:
216
- self.data['geometry'] = self.original_geometry
219
+ self = self.transform(self.BASE_SRID)
220
+ self.data['geometry'] = self.original_geometry
217
221
  await self.update(self.data)
218
222
  self.coordinates = data['geometry']['coordinates']
219
223
  except AttributeError:
224
+ if self.srid != self.BASE_SRID:
225
+ self = self.transform(self.BASE_SRID)
220
226
  endpoint = urljoin(self.layer.endpoint, 'features/')
221
- response = await self.layer.api.post(endpoint, data)
227
+ request_data = self.data.copy()
228
+ response = await self.layer.api.post(endpoint, request_data)
222
229
  self.endpoint = urljoin(self.layer.endpoint, f'features/{response["id"]}/')
223
230
  self.data.update(response)
224
231
 
232
+ self.data['geometry'] = data['geometry']
233
+ self._srid = srid
234
+
225
235
 
226
236
  async def delete(self) -> None:
227
237
  """
geobox/feature.py CHANGED
@@ -30,7 +30,17 @@ class Feature(Base):
30
30
  >>> from geobox import GeoboxClient, Feature
31
31
  >>> client = GeoboxClient()
32
32
  >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
33
- >>> feature = Feature(layer=layer, srid=4326) # example srid set to 4326
33
+ >>> geojson = {
34
+ ... "type": "Feature",
35
+ ... "geometry": {
36
+ ... "type": "Point",
37
+ ... "coordinates": [58.4, 23.6]
38
+ ... },
39
+ ... "properties": {
40
+ ... "name": "Test feature"
41
+ ... }
42
+ ... }
43
+ >>> feature = Feature(layer=layer, data=geojson, srid=4326) # example srid set to 4326
34
44
  >>> feature.save()
35
45
  """
36
46
  super().__init__(api=layer.api)
@@ -65,8 +75,9 @@ class Feature(Base):
65
75
  Returns:
66
76
  str: A string representation of the Feature object.
67
77
  """
68
- return f"Feature(id={self.id}, type={self.feature_type})"
69
-
78
+ feature_id = getattr(self, "id", "-1")
79
+ return f"Feature(id={feature_id}, type={self.feature_type})"
80
+
70
81
 
71
82
  def __getattr__(self, name: str) -> Any:
72
83
  """
@@ -217,18 +228,28 @@ class Feature(Base):
217
228
  >>> feature.save()
218
229
  """
219
230
  data = self.data.copy()
231
+ srid = self.srid
232
+
220
233
  try:
221
234
  if self.id:
222
235
  if self.srid != self.BASE_SRID:
223
- self.data['geometry'] = self.original_geometry
236
+ self = self.transform(self.BASE_SRID)
237
+ self.data['geometry'] = self.original_geometry
224
238
  self.update(self.data)
225
239
  self.coordinates = data['geometry']['coordinates']
226
240
  except AttributeError:
241
+ if self.srid != self.BASE_SRID:
242
+ self = self.transform(self.BASE_SRID)
227
243
  endpoint = urljoin(self.layer.endpoint, 'features/')
228
- response = self.layer.api.post(endpoint, data)
244
+ request_data = self.data.copy()
245
+ response = self.layer.api.post(endpoint, request_data)
229
246
  self.endpoint = urljoin(self.layer.endpoint, f'features/{response["id"]}/')
230
247
  self.data.update(response)
231
248
 
249
+ self.data['geometry'] = data['geometry']
250
+ self._srid = srid
251
+
252
+
232
253
 
233
254
  def delete(self) -> None:
234
255
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 2.2.0
3
+ Version: 2.2.1
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=cruV6MisWFnW0-XMij_IrqN6oQDzyCisKrDkssMlxZI,19209
10
+ geobox/feature.py,sha256=63AaEUkCnT9kbiEIh7LUqnuy2Op0qUPN_oQik0tjfFY,19924
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
@@ -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=ilYN-Do82U87dCqnTOU11kfW7HzgZHT5bwdUrspoTCs,19656
43
+ geobox/aio/feature.py,sha256=6YYZvKXccJ2chnhsyhOIrSCn3aaGEiVgvHRgslKEJ9Y,20012
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
@@ -65,8 +65,8 @@ geobox/aio/vectorlayer.py,sha256=flA3MQFD1Qm6TohftcTXfDQ5VGZztHr1K3zhZZ0x2og,593
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.0.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
69
- geobox-2.2.0.dist-info/METADATA,sha256=IvGypAZrXKUSApNTLY-ouOyVDoWT5iCuHvJ8JC5S6CI,3082
70
- geobox-2.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
71
- geobox-2.2.0.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
72
- geobox-2.2.0.dist-info/RECORD,,
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,,
File without changes