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/basemap.py CHANGED
@@ -1,196 +1,196 @@
1
- from typing import List, Dict, Optional, TYPE_CHECKING
2
- from urllib.parse import urljoin, urlencode
3
-
4
- from .base import AsyncBase
5
- from ..exception import NotFoundError
6
- from ..utils import clean_data
7
-
8
- if TYPE_CHECKING:
9
- from . import AsyncGeoboxClient
10
- from ..api import GeoboxClient as SyncGeoboxClient
11
- from ..basemap import Basemap as SyncBasemap
12
-
13
-
14
- class Basemap(AsyncBase):
15
-
16
- BASE_ENDPOINT = 'basemaps/'
17
-
18
- def __init__(self,
19
- api: 'AsyncGeoboxClient',
20
- data: Optional[Dict] = {}):
21
- """
22
- Initialize a basemap instance.
23
-
24
- Args:
25
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
26
- data (Dict): The data of the basemap.
27
- """
28
- super().__init__(api, data=data)
29
- self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}/"
30
-
31
-
32
- @classmethod
33
- async def get_basemaps(cls, api: 'AsyncGeoboxClient') -> List['Basemap']:
34
- """
35
- [async] Get a list of basemaps
36
-
37
- Args:
38
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
39
-
40
- Returns:
41
- List[BaseMap]: list of basemaps.
42
-
43
- Example:
44
- >>> from geobox.aio import AsyncGeoboxClient
45
- >>> from geobox.aio.basemap import Basemap
46
- >>> async with AsyncGeoboxClient() as client:
47
- >>> basemaps = await Basemap.get_basemaps(client)
48
- or
49
- >>> basemaps = await client.get_basemaps()
50
- """
51
- response = await api.get(cls.BASE_ENDPOINT)
52
- if not response:
53
- return []
54
-
55
- items = []
56
- for item in response:
57
- response[item]['name'] = item
58
- items.append(response[item])
59
-
60
- return [cls(api, item) for item in items]
61
-
62
-
63
- @classmethod
64
- async def get_basemap(cls, api: 'AsyncGeoboxClient', name: str) -> 'Basemap':
65
- """
66
- [async] Get a basemap object
67
-
68
- Args:
69
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
70
- name: the basemap name
71
-
72
- Returns:
73
- Basemap: the basemap object
74
-
75
- Raises:
76
- NotFoundError: if the base,ap with the specified name not found
77
-
78
- Example:
79
- >>> from geobox.aio import AsyncGeoboxClient
80
- >>> from geobox.aio.basemap import Basemap
81
- >>> async with AsyncGeoboxClient() as client:
82
- >>> basemap = await Basemap.get_basemap(client, name='test')
83
- or
84
- >>> basemap = await client.get_basemap(name='test')
85
- """
86
- response = await cls.get_basemaps(api)
87
- basemap = [basemap for basemap in response if basemap.name == name]
88
- if not basemap:
89
- raise NotFoundError(f'Basemap with name "{name}" not found.')
90
-
91
- return basemap[0]
92
-
93
-
94
- @property
95
- def thumbnail(self) -> str:
96
- """
97
- Get the thumbnail url of the basemap
98
-
99
- Returns:
100
- str: the thumbnail url
101
- """
102
- return super().thumbnail()
103
-
104
-
105
- @property
106
- def wmts(self) -> str:
107
- """
108
- Get the wmts url of the basemap
109
-
110
- Returns:
111
- str: the wmts url
112
- """
113
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
114
-
115
- if not self.api.access_token and self.api.apikey:
116
- endpoint = f"{endpoint}?apikey={self.api.apikey}"
117
-
118
- return endpoint
119
-
120
-
121
- @property
122
- async def server_url(self) -> str:
123
- """
124
- [async] Get the server url of the basemap
125
-
126
- Returns:
127
- str: the server url
128
- """
129
- endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
130
- return await self.api.get(endpoint)
131
-
132
-
133
- @property
134
- async def proxy_url(self) -> str:
135
- """
136
- [async] Get the proxy url of the basemap
137
-
138
- Returns:
139
- str: the proxy url
140
- """
141
- endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
142
- return await self.api.get(endpoint)
143
-
144
-
145
- @classmethod
146
- async def proxy_basemap(cls, api: 'response', url: str) -> None:
147
- """
148
- [async] Proxy the basemap
149
-
150
- Args:
151
- api (GeoboxClient): The GeoboxClient instance for making requests.
152
- url (str): the proxy server url.
153
-
154
- Returns:
155
- None
156
-
157
- Example:
158
- >>> from geobox.aio import AsyncGeoboxClient
159
- >>> from geobox.aio.basemap import Basemap
160
- >>> async with AsyncGeoboxClient() as client:
161
- >>> await Basemap.proxy_basemap(client, url='proxy_server_url')
162
- or
163
- >>> await client.proxy_basemap(url='proxy_server_url')
164
- """
165
- param = clean_data({
166
- 'url': url
167
- })
168
- query_string = urlencode(param)
169
- endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
170
- await api.get(endpoint)
171
-
172
-
173
- def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncBasemap':
174
- """
175
- Switch to sync version of the basemap instance to have access to the sync methods
176
-
177
- Args:
178
- sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
179
-
180
- Returns:
181
- geobox.basemap.Basemap: the sync instance of the basemap.
182
-
183
- Example:
184
- >>> from geobox import Geoboxclient
185
- >>> from geobox.aio import AsyncGeoboxClient
186
- >>> from geobox.aio.basemap import Basemap
187
- >>> client = GeoboxClient()
188
- >>> async with AsyncGeoboxClient() as async_client:
189
- >>> basemap = await Basemap.get_basemap(async_client, name='test')
190
- or
191
- >>> basemap = await async_client.get_basemap(name='test')
192
- >>> sync_basemap = basemap.to_sync(client)
193
- """
194
- from ..basemap import Basemap as SyncBasemap
195
-
196
- return SyncBasemap(api=sync_client, data=self.data)
1
+ from typing import List, Dict, Optional, TYPE_CHECKING
2
+ from urllib.parse import urljoin, urlencode
3
+
4
+ from .base import AsyncBase
5
+ from ..exception import NotFoundError
6
+ from ..utils import clean_data
7
+
8
+ if TYPE_CHECKING:
9
+ from . import AsyncGeoboxClient
10
+ from ..api import GeoboxClient
11
+ from ..basemap import Basemap
12
+
13
+
14
+ class AsyncBasemap(AsyncBase):
15
+
16
+ BASE_ENDPOINT = 'basemaps/'
17
+
18
+ def __init__(self,
19
+ api: 'AsyncGeoboxClient',
20
+ data: Optional[Dict] = {}):
21
+ """
22
+ Initialize a basemap instance.
23
+
24
+ Args:
25
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
26
+ data (Dict): The data of the basemap.
27
+ """
28
+ super().__init__(api, data=data)
29
+ self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}/"
30
+
31
+
32
+ @classmethod
33
+ async def get_basemaps(cls, api: 'AsyncGeoboxClient') -> List['AsyncBasemap']:
34
+ """
35
+ [async] Get a list of basemaps
36
+
37
+ Args:
38
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
39
+
40
+ Returns:
41
+ List[AsyncBaseMap]: list of basemaps.
42
+
43
+ Example:
44
+ >>> from geobox.aio import AsyncGeoboxClient
45
+ >>> from geobox.aio.basemap import AsyncBasemap
46
+ >>> async with AsyncGeoboxClient() as client:
47
+ >>> basemaps = await AsyncBasemap.get_basemaps(client)
48
+ or
49
+ >>> basemaps = await client.get_basemaps()
50
+ """
51
+ response = await api.get(cls.BASE_ENDPOINT)
52
+ if not response:
53
+ return []
54
+
55
+ items = []
56
+ for item in response:
57
+ response[item]['name'] = item
58
+ items.append(response[item])
59
+
60
+ return [cls(api, item) for item in items]
61
+
62
+
63
+ @classmethod
64
+ async def get_basemap(cls, api: 'AsyncGeoboxClient', name: str) -> 'AsyncBasemap':
65
+ """
66
+ [async] Get a basemap object
67
+
68
+ Args:
69
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
70
+ name: the basemap name
71
+
72
+ Returns:
73
+ AsyncBasemap: the basemap object
74
+
75
+ Raises:
76
+ NotFoundError: if the base,ap with the specified name not found
77
+
78
+ Example:
79
+ >>> from geobox.aio import AsyncGeoboxClient
80
+ >>> from geobox.aio.basemap import Basemap
81
+ >>> async with AsyncGeoboxClient() as client:
82
+ >>> basemap = await Basemap.get_basemap(client, name='test')
83
+ or
84
+ >>> basemap = await client.get_basemap(name='test')
85
+ """
86
+ response = await cls.get_basemaps(api)
87
+ basemap = [basemap for basemap in response if basemap.name == name]
88
+ if not basemap:
89
+ raise NotFoundError(f'Basemap with name "{name}" not found.')
90
+
91
+ return basemap[0]
92
+
93
+
94
+ @property
95
+ def thumbnail(self) -> str:
96
+ """
97
+ Get the thumbnail url of the basemap
98
+
99
+ Returns:
100
+ str: the thumbnail url
101
+ """
102
+ return super()._thumbnail()
103
+
104
+
105
+ @property
106
+ def wmts(self) -> str:
107
+ """
108
+ Get the wmts url of the basemap
109
+
110
+ Returns:
111
+ str: the wmts url
112
+ """
113
+ endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
114
+
115
+ if not self.api.access_token and self.api.apikey:
116
+ endpoint = f"{endpoint}?apikey={self.api.apikey}"
117
+
118
+ return endpoint
119
+
120
+
121
+ @property
122
+ async def server_url(self) -> str:
123
+ """
124
+ [async] Get the server url of the basemap
125
+
126
+ Returns:
127
+ str: the server url
128
+ """
129
+ endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
130
+ return await self.api.get(endpoint)
131
+
132
+
133
+ @property
134
+ async def proxy_url(self) -> str:
135
+ """
136
+ [async] Get the proxy url of the basemap
137
+
138
+ Returns:
139
+ str: the proxy url
140
+ """
141
+ endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
142
+ return await self.api.get(endpoint)
143
+
144
+
145
+ @classmethod
146
+ async def proxy_basemap(cls, api: 'response', url: str) -> None:
147
+ """
148
+ [async] Proxy the basemap
149
+
150
+ Args:
151
+ api (GeoboxClient): The GeoboxClient instance for making requests.
152
+ url (str): the proxy server url.
153
+
154
+ Returns:
155
+ None
156
+
157
+ Example:
158
+ >>> from geobox.aio import AsyncGeoboxClient
159
+ >>> from geobox.aio.basemap import Basemap
160
+ >>> async with AsyncGeoboxClient() as client:
161
+ >>> await Basemap.proxy_basemap(client, url='proxy_server_url')
162
+ or
163
+ >>> await client.proxy_basemap(url='proxy_server_url')
164
+ """
165
+ param = clean_data({
166
+ 'url': url
167
+ })
168
+ query_string = urlencode(param)
169
+ endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
170
+ await api.get(endpoint)
171
+
172
+
173
+ def to_sync(self, sync_client: 'GeoboxClient') -> 'Basemap':
174
+ """
175
+ Switch to sync version of the basemap instance to have access to the sync methods
176
+
177
+ Args:
178
+ sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
179
+
180
+ Returns:
181
+ Basemap: the sync instance of the basemap.
182
+
183
+ Example:
184
+ >>> from geobox import Geoboxclient
185
+ >>> from geobox.aio import AsyncGeoboxClient
186
+ >>> from geobox.aio.basemap import AsyncBasemap
187
+ >>> client = GeoboxClient()
188
+ >>> async with AsyncGeoboxClient() as async_client:
189
+ >>> basemap = await AsyncBasemap.get_basemap(async_client, name='test')
190
+ or
191
+ >>> basemap = await async_client.get_basemap(name='test')
192
+ >>> sync_basemap = basemap.to_sync(client)
193
+ """
194
+ from ..basemap import Basemap
195
+
196
+ return Basemap(api=sync_client, data=self.data)