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/field.py CHANGED
@@ -1,321 +1,315 @@
1
- from urllib.parse import urljoin
2
- from typing import Optional, Dict, TYPE_CHECKING, Any
3
-
4
- from .base import AsyncBase
5
- from ..utils import clean_data
6
- from ..enums import FieldType
7
-
8
- if TYPE_CHECKING:
9
- from .api import AsyncGeoboxClient
10
- from .vectorlayer import VectorLayer
11
- from ..api import GeoboxClient as SyncGeoboxClient
12
- from ..field import Field as SyncField
13
-
14
-
15
- class Field(AsyncBase):
16
-
17
- def __init__(self,
18
- layer: 'VectorLayer',
19
- data_type: 'FieldType',
20
- field_id: int = None,
21
- data: Optional[Dict] = {}):
22
- """
23
- Constructs all the necessary attributes for the Field object.
24
-
25
- Args:
26
- layer (VectorLayer): The vector layer that the field belongs to.
27
- data_type (FieldType): type of the field
28
- field_id (int): the id of the field
29
- data (Dict, optional): The data of the field.
30
- """
31
- super().__init__(api=layer.api, data=data)
32
- self.layer = layer
33
- self.field_id = field_id
34
- if not isinstance(data_type, FieldType):
35
- raise ValueError("data_type must be a FieldType instance")
36
- self.data_type = data_type
37
- self.endpoint = urljoin(layer.endpoint, f'fields/{self.id}/') if self.data.get('id') else None
38
-
39
-
40
- def __repr__(self) -> str:
41
- """
42
- Return a string representation of the field.
43
-
44
- Returns:
45
- str: The string representation of the field.
46
- """
47
- return f"Field(id={self.id}, name={self.name}, data_type={self.data_type})"
48
-
49
-
50
- def __getattr__(self, name: str) -> Any:
51
- """
52
- Get an attribute from the resource.
53
-
54
- Args:
55
- name (str): The name of the attribute
56
- """
57
- if name == 'datatype':
58
- return FieldType(self.data['datatype'])
59
- return super().__getattr__(name)
60
-
61
-
62
- @property
63
- def domain(self) -> Dict:
64
- """
65
- Domain property
66
-
67
- Returns:
68
- Dict: domain data
69
- """
70
- return self.data.get('domain')
71
-
72
-
73
- @domain.setter
74
- def domain(self, value: Dict) -> None:
75
- """
76
- Domain property setter
77
-
78
- Returns:
79
- None
80
- """
81
- self.data['domain'] = value
82
-
83
-
84
- @classmethod
85
- async def create_field(cls, api: 'AsyncGeoboxClient', layer: 'VectorLayer', name: str, data_type: 'FieldType', data: Dict = {}) -> 'Field':
86
- """
87
- [async] Create a new field
88
-
89
- Args:
90
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
91
- layer (VectorLayer): field's layer
92
- name (str): name of the field
93
- data_type (FieldType): type of the field
94
- data (Dict, optional): the data of the field
95
-
96
- Returns:
97
- Field: the created field object
98
-
99
- Example:
100
- >>> from geobox.aio import AsyncGeoboxClient
101
- >>> from geobox.aio.vectorlayer import VectorLayer
102
- >>> from geobox.aio.field import Field
103
- >>> async with AsyncGeoboxClient() as client:
104
- >>> layer = await client.get_layer(uuid="12345678-1234-5678-1234-567812345678")
105
- >>> field = await Field.create_field(client, layer=layer, name='test', data_type=FieldType.Integer)
106
- """
107
- data.update({
108
- "name": name,
109
- "datatype": data_type.value
110
- })
111
- endpoint = urljoin(layer.endpoint, 'fields/')
112
- return await super()._create(api, endpoint, data, factory_func=lambda api, item: Field(layer, data_type, item['id'], item))
113
-
114
-
115
- async def save(self) -> None:
116
- """
117
- [async] Save the field. Creates a new field if field_id is None, updates existing field otherwise.
118
-
119
- Returns:
120
- None
121
-
122
- Example:
123
- >>> from geobox.aio import AsyncGeoboxClient
124
- >>> from geobox.aio.field import Field
125
- >>> async with AsyncGeoboxClient() as client:
126
- >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
127
- >>> field = Field(layer=layer, data_type=FieldType.String)
128
- >>> await field.save()
129
- """
130
- data = clean_data({
131
- "name": self.name,
132
- "datatype": FieldType(self.data_type).value,
133
- "display_name": self.data.get("display_name"),
134
- "description": self.data.get("description"),
135
- "domain": self.data.get("domain"),
136
- "width": self.data.get("width"),
137
- "hyperlink": self.data.get("hyperlink")
138
- })
139
-
140
- try:
141
- if self.id:
142
- response = await self.layer.api.put(self.endpoint, data)
143
- except AttributeError:
144
- endpoint = urljoin(self.layer.endpoint, 'fields/')
145
- response = await self.layer.api.post(endpoint, data)
146
- self.id = response['id']
147
- self.endpoint = urljoin(self.layer.endpoint, f'fields/{self.id}/')
148
-
149
- self._update_properties(response)
150
-
151
-
152
- async def delete(self) -> None:
153
- """
154
- [async] Delete the field.
155
-
156
- Returns:
157
- None
158
-
159
- Example:
160
- >>> from geobox.aio import AsyncGeoboxClient
161
- >>> from geobox.aio.field import Field
162
- >>> async with AsyncGeoboxClient() as client:
163
- >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
164
- >>> field = await layer.get_field(name='test')
165
- >>> await field.delete()
166
- """
167
- await super().delete(self.endpoint)
168
- self.field_id = None
169
-
170
-
171
- async def update(self, **kwargs) -> Dict:
172
- """
173
- [async] Update the field.
174
-
175
- Keyword Args:
176
- name (str): The name of the field.
177
- display_name (str): The display name of the field.
178
- description (str): The description of the field.
179
- domain (Dict): the domain of the field
180
- width (int): The width of the field.
181
- hyperlink (bool): the hyperlink field.
182
-
183
- Returns:
184
- Dict: The updated data.
185
-
186
- Example:
187
- >>> from geobox.aio import AsyncGeoboxClient
188
- >>> from geobox.aio.field import Field
189
- >>> async with AsyncGeoboxClient() as client:
190
- >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
191
- >>> field = await layer.get_field(name='test')
192
- >>> field.update(name="my_field", display_name="My Field", description="My Field Description")
193
- """
194
- data = {
195
- "name": kwargs.get('name'),
196
- "display_name": kwargs.get('display_name'),
197
- "description": kwargs.get('description'),
198
- "domain": kwargs.get('domain'),
199
- "hyperlink": kwargs.get('hyperlink')
200
- }
201
- return await super()._update(self.endpoint, data)
202
-
203
-
204
- async def get_field_unique_values(self) -> Dict:
205
- """
206
- [async] Get the unique values of the field.
207
-
208
- Returns:
209
- Dict: The response data.
210
-
211
- Example:
212
- >>> from geobox.aio import AsyncGeoboxClient
213
- >>> from geobox.aio.field import Field
214
- >>> async with AsyncGeoboxClient() as client:
215
- >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
216
- >>> field = await layer.get_field(name='test')
217
- >>> await field.get_field_unique_values()
218
- """
219
- endpoint = urljoin(self.endpoint, 'distinct/')
220
- return await self.layer.api.get(endpoint)
221
-
222
-
223
- async def get_field_unique_values_numbers(self) -> int:
224
- """
225
- [async] Get the count of unique values of the field.
226
-
227
- Returns:
228
- int: The count of the field unique values.
229
-
230
- Example:
231
- >>> from geobox.aio import AsyncGeoboxClient
232
- >>> from geobox.aio.field import Field
233
- >>> async with AsyncGeoboxClient() as client:
234
- >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
235
- >>> field = awaitlayer.get_field(name='test')
236
- >>> await field.get_field_unique_values_numbers()
237
- """
238
- endpoint = urljoin(self.endpoint, 'distinctCount/')
239
- return await self.layer.api.get(endpoint)
240
-
241
-
242
- async def get_field_statistic(self, func: str) -> Dict:
243
- """
244
- [async] Get the statistic of the field.
245
-
246
- Args:
247
- func (str): The function to apply to the field. values are: min, max, avg
248
-
249
- Returns:
250
- Dict: The response data.
251
-
252
- Example:
253
- >>> from geobox.aio import AsyncGeoboxClient
254
- >>> from geobox.aio.field import Field
255
- >>> async with AsyncGeoboxClient() as client:
256
- >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
257
- >>> field = await layer.get_field(name='test')
258
- >>> await field.get_field_statistic(func='avg')
259
- """
260
- endpoint = urljoin(self.endpoint, f'stats/?func_type={func}')
261
- return await self.layer.api.get(endpoint)
262
-
263
-
264
- async def update_domain(self, range_domain: Dict = None, list_domain: Dict = None) -> Dict:
265
- """
266
- [async] Update field domian values
267
-
268
- Args:
269
- range_domain (Dict): a dictionary with min and max keys.
270
- list_domain (Dict): a dictionary containing the domain codes and values.
271
-
272
- Returns:
273
- Dict: the updated field domain
274
-
275
- Example:
276
- >>> from geobox.aio import AsyncGeoboxClient
277
- >>> async with AsyncGeoboxClient() as client:
278
- >>> field = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0]
279
- >>> range_d = {'min': 1, 'max': 10}
280
- >>> list_d = {'1': 'value1', '2': 'value2'}
281
- >>> await field.update_domain(range_domain = range_d, list_domain=list_d)
282
- {'min': 1, 'max': 10, 'items: {'1': 'value1', '2': 'value2'}}
283
- """
284
- if not self.domain:
285
- self.domain = {'min': None, 'max': None, 'items': {}}
286
-
287
- if range_domain:
288
- self.domain['min'] = range_domain['min']
289
- self.domain['max'] = range_domain['max']
290
-
291
- if list_domain:
292
- self.domain['items'] = {**self.domain['items'], **list_domain}
293
-
294
- await self.save()
295
- return self.domain
296
-
297
-
298
- def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncField':
299
- """
300
- Switch to sync version of the field instance to have access to the sync methods
301
-
302
- Args:
303
- sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
304
-
305
- Returns:
306
- geobox.field.Field: the sync instance of the field.
307
-
308
- Example:
309
- >>> from geobox import Geoboxclient
310
- >>> from geobox.aio import AsyncGeoboxClient
311
- >>> from geobox.aio.field import Field
312
- >>> client = GeoboxClient()
313
- >>> async with AsyncGeoboxClient() as async_client:
314
- >>> layer = await async_client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
315
- >>> field = await layer.get_field(name='test')
316
- >>> sync_field = field.to_sync(client)
317
- """
318
- from ..field import Field as SyncField
319
-
320
- sync_layer = self.layer.to_sync(sync_client=sync_client)
321
- return SyncField(layer=sync_layer, data_type=self.data_type, field_id=self.field_id, data=self.data)
1
+ from urllib.parse import urljoin
2
+ from typing import Optional, Dict, TYPE_CHECKING, Any
3
+
4
+ from .base import AsyncBase
5
+ from ..utils import clean_data
6
+ from ..enums import FieldType
7
+
8
+ if TYPE_CHECKING:
9
+ from .api import AsyncGeoboxClient
10
+ from .vectorlayer import VectorLayer
11
+ from ..api import GeoboxClient
12
+ from ..field import Field
13
+
14
+
15
+ class AsyncField(AsyncBase):
16
+
17
+ def __init__(self,
18
+ layer: 'VectorLayer',
19
+ data_type: 'FieldType',
20
+ field_id: int = None,
21
+ data: Optional[Dict] = {}):
22
+ """
23
+ Constructs all the necessary attributes for the Field object.
24
+
25
+ Args:
26
+ layer (VectorLayer): The vector layer that the field belongs to.
27
+ data_type (FieldType): type of the field
28
+ field_id (int): the id of the field
29
+ data (Dict, optional): The data of the field.
30
+ """
31
+ super().__init__(api=layer.api, data=data)
32
+ self.layer = layer
33
+ self.field_id = field_id
34
+ if not isinstance(data_type, FieldType):
35
+ raise ValueError("data_type must be a FieldType instance")
36
+ self.data_type = data_type
37
+ self.endpoint = urljoin(layer.endpoint, f'fields/{self.id}/') if self.data.get('id') else None
38
+
39
+
40
+ def __repr__(self) -> str:
41
+ """
42
+ Return a string representation of the field.
43
+
44
+ Returns:
45
+ str: The string representation of the field.
46
+ """
47
+ return f"AsyncField(id={self.id}, name={self.name}, data_type={self.data_type})"
48
+
49
+
50
+ def __getattr__(self, name: str) -> Any:
51
+ """
52
+ Get an attribute from the resource.
53
+
54
+ Args:
55
+ name (str): The name of the attribute
56
+ """
57
+ if name == 'datatype':
58
+ return FieldType(self.data['datatype'])
59
+ return super().__getattr__(name)
60
+
61
+
62
+ @property
63
+ def domain(self) -> Dict:
64
+ """
65
+ Domain property
66
+
67
+ Returns:
68
+ Dict: domain data
69
+ """
70
+ return self.data.get('domain')
71
+
72
+
73
+ @domain.setter
74
+ def domain(self, value: Dict) -> None:
75
+ """
76
+ Domain property setter
77
+
78
+ Returns:
79
+ None
80
+ """
81
+ self.data['domain'] = value
82
+
83
+
84
+ @classmethod
85
+ async def create_field(cls, api: 'AsyncGeoboxClient', layer: 'VectorLayer', name: str, data_type: 'FieldType', data: Dict = {}) -> 'AsyncField':
86
+ """
87
+ [async] Create a new field
88
+
89
+ Args:
90
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
91
+ layer (VectorLayer): field's layer
92
+ name (str): name of the field
93
+ data_type (FieldType): type of the field
94
+ data (Dict, optional): the data of the field
95
+
96
+ Returns:
97
+ AsyncField: the created field object
98
+
99
+ Example:
100
+ >>> from geobox.aio import AsyncGeoboxClient
101
+ >>> from geobox.aio.vectorlayer import VectorLayer
102
+ >>> from geobox.aio.field import AsyncField
103
+ >>> async with AsyncGeoboxClient() as client:
104
+ >>> layer = await client.get_layer(uuid="12345678-1234-5678-1234-567812345678")
105
+ >>> field = await AsyncField.create_field(client, layer=layer, name='test', data_type=FieldType.Integer)
106
+ """
107
+ data.update({
108
+ "name": name,
109
+ "datatype": data_type.value
110
+ })
111
+ endpoint = urljoin(layer.endpoint, 'fields/')
112
+ return await super()._create(api, endpoint, data, factory_func=lambda api, item: AsyncField(layer, data_type, item['id'], item))
113
+
114
+
115
+ async def save(self) -> None:
116
+ """
117
+ [async] Save the field. Creates a new field if field_id is None, updates existing field otherwise.
118
+
119
+ Returns:
120
+ None
121
+
122
+ Example:
123
+ >>> from geobox.aio import AsyncGeoboxClient
124
+ >>> from geobox.aio.field import AsyncField
125
+ >>> async with AsyncGeoboxClient() as client:
126
+ >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
127
+ >>> field = AsyncField(layer=layer, data_type=FieldType.String)
128
+ >>> await field.save()
129
+ """
130
+ data = clean_data({
131
+ "name": self.name,
132
+ "datatype": FieldType(self.data_type).value,
133
+ "display_name": self.data.get("display_name"),
134
+ "description": self.data.get("description"),
135
+ "domain": self.data.get("domain"),
136
+ "width": self.data.get("width"),
137
+ "hyperlink": self.data.get("hyperlink")
138
+ })
139
+
140
+ try:
141
+ if self.id:
142
+ response = await self.layer.api.put(self.endpoint, data)
143
+ except AttributeError:
144
+ endpoint = urljoin(self.layer.endpoint, 'fields/')
145
+ response = await self.layer.api.post(endpoint, data)
146
+ self.id = response['id']
147
+ self.endpoint = urljoin(self.layer.endpoint, f'fields/{self.id}/')
148
+
149
+ self._update_properties(response)
150
+
151
+
152
+ async def delete(self) -> None:
153
+ """
154
+ [async] Delete the field.
155
+
156
+ Returns:
157
+ None
158
+
159
+ Example:
160
+ >>> from geobox.aio import AsyncGeoboxClient
161
+ >>> async with AsyncGeoboxClient() as client:
162
+ >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
163
+ >>> field = await layer.get_field(name='test')
164
+ >>> await field.delete()
165
+ """
166
+ await super()._delete(self.endpoint)
167
+ self.field_id = None
168
+
169
+
170
+ async def update(self, **kwargs) -> Dict:
171
+ """
172
+ [async] Update the field.
173
+
174
+ Keyword Args:
175
+ name (str): The name of the field.
176
+ display_name (str): The display name of the field.
177
+ description (str): The description of the field.
178
+ domain (Dict): the domain of the field
179
+ width (int): The width of the field.
180
+ hyperlink (bool): the hyperlink field.
181
+
182
+ Returns:
183
+ Dict: The updated data.
184
+
185
+ Example:
186
+ >>> from geobox.aio import AsyncGeoboxClient
187
+ >>> async with AsyncGeoboxClient() as client:
188
+ >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
189
+ >>> field = await layer.get_field(name='test')
190
+ >>> field.update(name="my_field", display_name="My Field", description="My Field Description")
191
+ """
192
+ data = {
193
+ "name": kwargs.get('name'),
194
+ "display_name": kwargs.get('display_name'),
195
+ "description": kwargs.get('description'),
196
+ "domain": kwargs.get('domain'),
197
+ "hyperlink": kwargs.get('hyperlink')
198
+ }
199
+ return await super()._update(self.endpoint, data)
200
+
201
+
202
+ async def get_field_unique_values(self) -> Dict:
203
+ """
204
+ [async] Get the unique values of the field.
205
+
206
+ Returns:
207
+ Dict: The response data.
208
+
209
+ Example:
210
+ >>> from geobox.aio import AsyncGeoboxClient
211
+ >>> async with AsyncGeoboxClient() as client:
212
+ >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
213
+ >>> field = await layer.get_field(name='test')
214
+ >>> await field.get_field_unique_values()
215
+ """
216
+ endpoint = urljoin(self.endpoint, 'distinct/')
217
+ return await self.layer.api.get(endpoint)
218
+
219
+
220
+ async def get_field_unique_values_numbers(self) -> int:
221
+ """
222
+ [async] Get the count of unique values of the field.
223
+
224
+ Returns:
225
+ int: The count of the field unique values.
226
+
227
+ Example:
228
+ >>> from geobox.aio import AsyncGeoboxClient
229
+ >>> async with AsyncGeoboxClient() as client:
230
+ >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
231
+ >>> field = await layer.get_field(name='test')
232
+ >>> await field.get_field_unique_values_numbers()
233
+ """
234
+ endpoint = urljoin(self.endpoint, 'distinctCount/')
235
+ return await self.layer.api.get(endpoint)
236
+
237
+
238
+ async def get_field_statistic(self, func: str) -> Dict:
239
+ """
240
+ [async] Get the statistic of the field.
241
+
242
+ Args:
243
+ func (str): The function to apply to the field. values are: min, max, avg
244
+
245
+ Returns:
246
+ Dict: The response data.
247
+
248
+ Example:
249
+ >>> from geobox.aio import AsyncGeoboxClient
250
+ >>> async with AsyncGeoboxClient() as client:
251
+ >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
252
+ >>> field = await layer.get_field(name='test')
253
+ >>> await field.get_field_statistic(func='avg')
254
+ """
255
+ endpoint = urljoin(self.endpoint, f'stats/?func_type={func}')
256
+ return await self.layer.api.get(endpoint)
257
+
258
+
259
+ async def update_domain(self, range_domain: Dict = None, list_domain: Dict = None) -> Dict:
260
+ """
261
+ [async] Update field domian values
262
+
263
+ Args:
264
+ range_domain (Dict): a dictionary with min and max keys.
265
+ list_domain (Dict): a dictionary containing the domain codes and values.
266
+
267
+ Returns:
268
+ Dict: the updated field domain
269
+
270
+ Example:
271
+ >>> from geobox.aio import AsyncGeoboxClient
272
+ >>> async with AsyncGeoboxClient() as client:
273
+ >>> field = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0]
274
+ >>> range_d = {'min': 1, 'max': 10}
275
+ >>> list_d = {'1': 'value1', '2': 'value2'}
276
+ >>> await field.update_domain(range_domain = range_d, list_domain=list_d)
277
+ {'min': 1, 'max': 10, 'items: {'1': 'value1', '2': 'value2'}}
278
+ """
279
+ if not self.domain:
280
+ self.domain = {'min': None, 'max': None, 'items': {}}
281
+
282
+ if range_domain:
283
+ self.domain['min'] = range_domain['min']
284
+ self.domain['max'] = range_domain['max']
285
+
286
+ if list_domain:
287
+ self.domain['items'] = {**self.domain['items'], **list_domain}
288
+
289
+ await self.save()
290
+ return self.domain
291
+
292
+
293
+ def to_sync(self, sync_client: 'GeoboxClient') -> 'Field':
294
+ """
295
+ Switch to sync version of the field instance to have access to the sync methods
296
+
297
+ Args:
298
+ sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
299
+
300
+ Returns:
301
+ Field: the sync instance of the field.
302
+
303
+ Example:
304
+ >>> from geobox import Geoboxclient
305
+ >>> from geobox.aio import AsyncGeoboxClient
306
+ >>> client = GeoboxClient()
307
+ >>> async with AsyncGeoboxClient() as async_client:
308
+ >>> layer = await async_client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
309
+ >>> field = await layer.get_field(name='test')
310
+ >>> sync_field = field.to_sync(client)
311
+ """
312
+ from ..field import Field
313
+
314
+ sync_layer = self.layer.to_sync(sync_client=sync_client)
315
+ return Field(layer=sync_layer, data_type=self.data_type, field_id=self.field_id, data=self.data)