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/field.py CHANGED
@@ -1,321 +1,321 @@
1
- from urllib.parse import urljoin
2
- from typing import Optional, Dict, TYPE_CHECKING, Any
3
-
4
- from .base import Base
5
- from .utils import clean_data
6
- from .enums import FieldType
7
-
8
- if TYPE_CHECKING:
9
- from .api import GeoboxClient
10
- from .vectorlayer import VectorLayer
11
- from .aio import AsyncGeoboxClient
12
- from .aio.field import Field as AsyncField
13
-
14
-
15
- class Field(Base):
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
- def create_field(cls, api: 'GeoboxClient', layer: 'VectorLayer', name: str, data_type: 'FieldType', data: Dict = {}) -> 'Field':
86
- """
87
- Create a new field
88
-
89
- Args:
90
- api (GeoboxClient): The GeoboxClient 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 import GeoboxClient
101
- >>> from geobox.vectorlayer import VectorLayer
102
- >>> from geobox.field import Field
103
- >>> client = GeoboxClient()
104
- >>> layer = client.get_layer(uuid="12345678-1234-5678-1234-567812345678")
105
- >>> field = 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 super()._create(api, endpoint, data, factory_func=lambda api, item: Field(layer, data_type, item['id'], item))
113
-
114
-
115
- def save(self) -> None:
116
- """
117
- 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 import GeoboxClient
124
- >>> from geobox.field import Field
125
- >>> client = GeoboxClient()
126
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
127
- >>> field = Field(layer=layer, data_type=FieldType.String)
128
- >>> 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 = self.layer.api.put(self.endpoint, data)
143
- except AttributeError:
144
- endpoint = urljoin(self.layer.endpoint, 'fields/')
145
- response = 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
- def delete(self) -> None:
153
- """
154
- Delete the field.
155
-
156
- Returns:
157
- None
158
-
159
- Example:
160
- >>> from geobox import GeoboxClient
161
- >>> from geobox.field import Field
162
- >>> client = GeoboxClient()
163
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
164
- >>> field = layer.get_field(name='test')
165
- >>> field.delete()
166
- """
167
- super().delete(self.endpoint)
168
- self.field_id = None
169
-
170
-
171
- def update(self, **kwargs) -> Dict:
172
- """
173
- 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 import GeoboxClient
188
- >>> from geobox.field import Field
189
- >>> client = GeoboxClient()
190
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
191
- >>> field = 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 super()._update(self.endpoint, data)
202
-
203
-
204
- def get_field_unique_values(self) -> Dict:
205
- """
206
- Get the unique values of the field.
207
-
208
- Returns:
209
- Dict: The response data.
210
-
211
- Example:
212
- >>> from geobox import GeoboxClient
213
- >>> from geobox.field import Field
214
- >>> client = GeoboxClient()
215
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
216
- >>> field = layer.get_field(name='test')
217
- >>> field.get_field_unique_values()
218
- """
219
- endpoint = urljoin(self.endpoint, 'distinct/')
220
- return self.layer.api.get(endpoint)
221
-
222
-
223
- def get_field_unique_values_numbers(self) -> int:
224
- """
225
- 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 import GeoboxClient
232
- >>> from geobox.field import Field
233
- >>> client = GeoboxClient()
234
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
235
- >>> field = layer.get_field(name='test')
236
- >>> field.get_field_unique_values_numbers()
237
- """
238
- endpoint = urljoin(self.endpoint, 'distinctCount/')
239
- return self.layer.api.get(endpoint)
240
-
241
-
242
- def get_field_statistic(self, func: str) -> Dict:
243
- """
244
- 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 import GeoboxClient
254
- >>> from geobox.field import Field
255
- >>> client = GeoboxClient()
256
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
257
- >>> field = layer.get_field(name='test')
258
- >>> field.get_field_statistic(func='avg')
259
- """
260
- endpoint = urljoin(self.endpoint, f'stats/?func_type={func}')
261
- return self.layer.api.get(endpoint)
262
-
263
-
264
- def update_domain(self, range_domain: Dict = None, list_domain: Dict = None) -> Dict:
265
- """
266
- 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 import GeoboxClient
277
- >>> client = GeoboxClient()
278
- >>> field = 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
- >>> 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
- self.save()
295
- return self.domain
296
-
297
-
298
- def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncField':
299
- """
300
- Switch to async version of the field instance to have access to the async methods
301
-
302
- Args:
303
- async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
304
-
305
- Returns:
306
- geobox.aio.field.Field: the async instance of the field.
307
-
308
- Example:
309
- >>> from geobox import Geoboxclient
310
- >>> from geobox.aio import AsyncGeoboxClient
311
- >>> from geobox.field import Field
312
- >>> client = GeoboxClient()
313
- >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
314
- >>> field = layer.get_field(name='test')
315
- >>> async with AsyncGeoboxClient() as async_client:
316
- >>> async_field = field.to_async(async_client)
317
- """
318
- from .aio.field import Field as AsyncField
319
-
320
- async_layer = self.layer.to_async(async_client=async_client)
1
+ from urllib.parse import urljoin
2
+ from typing import Optional, Dict, TYPE_CHECKING, Any
3
+
4
+ from .base import Base
5
+ from .utils import clean_data
6
+ from .enums import FieldType
7
+
8
+ if TYPE_CHECKING:
9
+ from .api import GeoboxClient
10
+ from .vectorlayer import VectorLayer
11
+ from .aio import AsyncGeoboxClient
12
+ from .aio.field import AsyncField
13
+
14
+
15
+ class Field(Base):
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
+ def create_field(cls, api: 'GeoboxClient', layer: 'VectorLayer', name: str, data_type: 'FieldType', data: Dict = {}) -> 'Field':
86
+ """
87
+ Create a new field
88
+
89
+ Args:
90
+ api (GeoboxClient): The GeoboxClient 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 import GeoboxClient
101
+ >>> from geobox.vectorlayer import VectorLayer
102
+ >>> from geobox.field import Field
103
+ >>> client = GeoboxClient()
104
+ >>> layer = client.get_layer(uuid="12345678-1234-5678-1234-567812345678")
105
+ >>> field = 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 super()._create(api, endpoint, data, factory_func=lambda api, item: Field(layer, data_type, item['id'], item))
113
+
114
+
115
+ def save(self) -> None:
116
+ """
117
+ 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 import GeoboxClient
124
+ >>> from geobox.field import Field
125
+ >>> client = GeoboxClient()
126
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
127
+ >>> field = Field(layer=layer, data_type=FieldType.String)
128
+ >>> 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 = self.layer.api.put(self.endpoint, data)
143
+ except AttributeError:
144
+ endpoint = urljoin(self.layer.endpoint, 'fields/')
145
+ response = 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
+ def delete(self) -> None:
153
+ """
154
+ Delete the field.
155
+
156
+ Returns:
157
+ None
158
+
159
+ Example:
160
+ >>> from geobox import GeoboxClient
161
+ >>> from geobox.field import Field
162
+ >>> client = GeoboxClient()
163
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
164
+ >>> field = layer.get_field(name='test')
165
+ >>> field.delete()
166
+ """
167
+ super()._delete(self.endpoint)
168
+ self.field_id = None
169
+
170
+
171
+ def update(self, **kwargs) -> Dict:
172
+ """
173
+ 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 import GeoboxClient
188
+ >>> from geobox.field import Field
189
+ >>> client = GeoboxClient()
190
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
191
+ >>> field = 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 super()._update(self.endpoint, data)
202
+
203
+
204
+ def get_field_unique_values(self) -> Dict:
205
+ """
206
+ Get the unique values of the field.
207
+
208
+ Returns:
209
+ Dict: The response data.
210
+
211
+ Example:
212
+ >>> from geobox import GeoboxClient
213
+ >>> from geobox.field import Field
214
+ >>> client = GeoboxClient()
215
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
216
+ >>> field = layer.get_field(name='test')
217
+ >>> field.get_field_unique_values()
218
+ """
219
+ endpoint = urljoin(self.endpoint, 'distinct/')
220
+ return self.layer.api.get(endpoint)
221
+
222
+
223
+ def get_field_unique_values_numbers(self) -> int:
224
+ """
225
+ 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 import GeoboxClient
232
+ >>> from geobox.field import Field
233
+ >>> client = GeoboxClient()
234
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
235
+ >>> field = layer.get_field(name='test')
236
+ >>> field.get_field_unique_values_numbers()
237
+ """
238
+ endpoint = urljoin(self.endpoint, 'distinctCount/')
239
+ return self.layer.api.get(endpoint)
240
+
241
+
242
+ def get_field_statistic(self, func: str) -> Dict:
243
+ """
244
+ 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 import GeoboxClient
254
+ >>> from geobox.field import Field
255
+ >>> client = GeoboxClient()
256
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
257
+ >>> field = layer.get_field(name='test')
258
+ >>> field.get_field_statistic(func='avg')
259
+ """
260
+ endpoint = urljoin(self.endpoint, f'stats/?func_type={func}')
261
+ return self.layer.api.get(endpoint)
262
+
263
+
264
+ def update_domain(self, range_domain: Dict = None, list_domain: Dict = None) -> Dict:
265
+ """
266
+ 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 import GeoboxClient
277
+ >>> client = GeoboxClient()
278
+ >>> field = 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
+ >>> 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
+ self.save()
295
+ return self.domain
296
+
297
+
298
+ def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncField':
299
+ """
300
+ Switch to async version of the field instance to have access to the async methods
301
+
302
+ Args:
303
+ async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
304
+
305
+ Returns:
306
+ AsyncField: the async instance of the field.
307
+
308
+ Example:
309
+ >>> from geobox import Geoboxclient
310
+ >>> from geobox.aio import AsyncGeoboxClient
311
+ >>> from geobox.field import Field
312
+ >>> client = GeoboxClient()
313
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
314
+ >>> field = layer.get_field(name='test')
315
+ >>> async with AsyncGeoboxClient() as async_client:
316
+ >>> async_field = field.to_async(async_client)
317
+ """
318
+ from .aio.field import AsyncField
319
+
320
+ async_layer = self.layer.to_async(async_client=async_client)
321
321
  return AsyncField(layer=async_layer, data_type=self.data_type, field_id=self.field_id, data=self.data)