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.
- geobox/__init__.py +61 -63
- geobox/aio/__init__.py +61 -63
- geobox/aio/api.py +491 -574
- geobox/aio/apikey.py +263 -263
- geobox/aio/attachment.py +341 -339
- geobox/aio/base.py +261 -262
- geobox/aio/basemap.py +196 -196
- geobox/aio/dashboard.py +340 -342
- geobox/aio/feature.py +35 -35
- geobox/aio/field.py +315 -321
- geobox/aio/file.py +72 -72
- geobox/aio/layout.py +340 -341
- geobox/aio/log.py +23 -23
- geobox/aio/map.py +1033 -1034
- geobox/aio/model3d.py +415 -415
- geobox/aio/mosaic.py +696 -696
- geobox/aio/plan.py +314 -314
- geobox/aio/query.py +693 -693
- geobox/aio/raster.py +88 -454
- geobox/aio/{analysis.py → raster_analysis.py} +153 -170
- geobox/aio/route.py +4 -4
- geobox/aio/scene.py +340 -342
- geobox/aio/settings.py +18 -18
- geobox/aio/task.py +404 -402
- geobox/aio/tile3d.py +337 -339
- geobox/aio/tileset.py +102 -103
- geobox/aio/usage.py +52 -51
- geobox/aio/user.py +506 -507
- geobox/aio/vector_tool.py +1968 -0
- geobox/aio/vectorlayer.py +316 -414
- geobox/aio/version.py +272 -273
- geobox/aio/view.py +1019 -983
- geobox/aio/workflow.py +340 -341
- geobox/api.py +14 -98
- geobox/apikey.py +262 -262
- geobox/attachment.py +336 -337
- geobox/base.py +384 -384
- geobox/basemap.py +194 -194
- geobox/dashboard.py +339 -341
- geobox/enums.py +31 -1
- geobox/feature.py +31 -10
- geobox/field.py +320 -320
- geobox/file.py +4 -4
- geobox/layout.py +339 -340
- geobox/log.py +4 -4
- geobox/map.py +1031 -1032
- geobox/model3d.py +410 -410
- geobox/mosaic.py +696 -696
- geobox/plan.py +313 -313
- geobox/query.py +691 -691
- geobox/raster.py +5 -368
- geobox/{analysis.py → raster_analysis.py} +108 -128
- geobox/scene.py +341 -342
- geobox/settings.py +194 -194
- geobox/task.py +399 -400
- geobox/tile3d.py +337 -338
- geobox/tileset.py +4 -4
- geobox/usage.py +3 -3
- geobox/user.py +503 -503
- geobox/vector_tool.py +1968 -0
- geobox/vectorlayer.py +5 -110
- geobox/version.py +272 -272
- geobox/view.py +981 -981
- geobox/workflow.py +338 -339
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/METADATA +15 -1
- geobox-2.2.1.dist-info/RECORD +72 -0
- geobox-2.1.0.dist-info/RECORD +0 -70
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/WHEEL +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/top_level.txt +0 -0
geobox/basemap.py
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
from typing import List, Dict, Optional, TYPE_CHECKING
|
|
2
|
-
from urllib.parse import urljoin, urlencode
|
|
3
|
-
|
|
4
|
-
from .base import Base
|
|
5
|
-
from .exception import NotFoundError
|
|
6
|
-
from .utils import clean_data
|
|
7
|
-
|
|
8
|
-
if TYPE_CHECKING:
|
|
9
|
-
from . import GeoboxClient
|
|
10
|
-
from .aio import AsyncGeoboxClient
|
|
11
|
-
from .aio.basemap import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Basemap(Base):
|
|
15
|
-
|
|
16
|
-
BASE_ENDPOINT = 'basemaps/'
|
|
17
|
-
|
|
18
|
-
def __init__(self,
|
|
19
|
-
api: 'GeoboxClient',
|
|
20
|
-
data: Optional[Dict] = {}):
|
|
21
|
-
"""
|
|
22
|
-
Initialize a basemap instance.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
api (GeoboxClient): The GeoboxClient 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
|
-
def get_basemaps(cls, api: 'GeoboxClient') -> List['Basemap']:
|
|
34
|
-
"""
|
|
35
|
-
Get a list of basemaps
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
39
|
-
|
|
40
|
-
Returns:
|
|
41
|
-
List[BaseMap]: list of basemaps.
|
|
42
|
-
|
|
43
|
-
Example:
|
|
44
|
-
>>> from geobox import GeoboxClient
|
|
45
|
-
>>> from geobox.basemap import Basemap
|
|
46
|
-
>>> client = GeoboxClient()
|
|
47
|
-
>>> basemaps = Basemap.get_basemaps(client)
|
|
48
|
-
or
|
|
49
|
-
>>> basemaps = client.get_basemaps()
|
|
50
|
-
"""
|
|
51
|
-
response = 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
|
-
def get_basemap(cls, api: 'GeoboxClient', name: str) -> 'Basemap':
|
|
65
|
-
"""
|
|
66
|
-
Get a basemap object
|
|
67
|
-
|
|
68
|
-
Args:
|
|
69
|
-
api (GeoboxClient): The GeoboxClient 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 import GeoboxClient
|
|
80
|
-
>>> from geobox.basemap import Basemap
|
|
81
|
-
>>> client = GeoboxClient()
|
|
82
|
-
>>> basemap = Basemap.get_basemap(client, name='test')
|
|
83
|
-
or
|
|
84
|
-
>>> basemap = client.get_basemap(name='test')
|
|
85
|
-
"""
|
|
86
|
-
basemap = [basemap for basemap in cls.get_basemaps(api) if basemap.name == name]
|
|
87
|
-
if not basemap:
|
|
88
|
-
raise NotFoundError(f'Basemap with name "{name}" not found.')
|
|
89
|
-
|
|
90
|
-
return basemap[0]
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@property
|
|
94
|
-
def thumbnail(self) -> str:
|
|
95
|
-
"""
|
|
96
|
-
Get the thumbnail url of the basemap
|
|
97
|
-
|
|
98
|
-
Returns:
|
|
99
|
-
str: the thumbnail url
|
|
100
|
-
"""
|
|
101
|
-
return super().
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
@property
|
|
105
|
-
def wmts(self) -> str:
|
|
106
|
-
"""
|
|
107
|
-
Get the wmts url of the basemap
|
|
108
|
-
|
|
109
|
-
Returns:
|
|
110
|
-
str: the wmts url
|
|
111
|
-
"""
|
|
112
|
-
endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
|
|
113
|
-
|
|
114
|
-
if not self.api.access_token and self.api.apikey:
|
|
115
|
-
endpoint = f"{endpoint}?apikey={self.api.apikey}"
|
|
116
|
-
|
|
117
|
-
return endpoint
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def server_url(self) -> str:
|
|
122
|
-
"""
|
|
123
|
-
Get the server url of the basemap
|
|
124
|
-
|
|
125
|
-
Returns:
|
|
126
|
-
str: the server url
|
|
127
|
-
"""
|
|
128
|
-
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
|
|
129
|
-
return self.api.get(endpoint)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
@property
|
|
133
|
-
def proxy_url(self) -> str:
|
|
134
|
-
"""
|
|
135
|
-
Get the proxy url of the basemap
|
|
136
|
-
|
|
137
|
-
Returns:
|
|
138
|
-
str: the proxy url
|
|
139
|
-
"""
|
|
140
|
-
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
|
|
141
|
-
return self.api.get(endpoint)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
@classmethod
|
|
145
|
-
def proxy_basemap(cls, api: 'GeoboxClient', url: str) -> None:
|
|
146
|
-
"""
|
|
147
|
-
Proxy the basemap
|
|
148
|
-
|
|
149
|
-
Args:
|
|
150
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
151
|
-
url (str): the proxy server url.
|
|
152
|
-
|
|
153
|
-
Returns:
|
|
154
|
-
None
|
|
155
|
-
|
|
156
|
-
Example:
|
|
157
|
-
>>> from geobox import GeoboxClient
|
|
158
|
-
>>> from geobox.basemap import Basemap
|
|
159
|
-
>>> client = GeoboxClient()
|
|
160
|
-
>>> Basemap.proxy_basemap(client, url='proxy_server_url')
|
|
161
|
-
or
|
|
162
|
-
>>> client.proxy_basemap(url='proxy_server_url')
|
|
163
|
-
"""
|
|
164
|
-
param = clean_data({
|
|
165
|
-
'url': url
|
|
166
|
-
})
|
|
167
|
-
query_string = urlencode(param)
|
|
168
|
-
endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
|
|
169
|
-
api.get(endpoint)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncBasemap':
|
|
173
|
-
"""
|
|
174
|
-
Switch to async version of the basemap instance to have access to the async methods
|
|
175
|
-
|
|
176
|
-
Args:
|
|
177
|
-
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
178
|
-
|
|
179
|
-
Returns:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Example:
|
|
183
|
-
>>> from geobox import Geoboxclient
|
|
184
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
185
|
-
>>> from geobox.basemap import Basemap
|
|
186
|
-
>>> client = GeoboxClient()
|
|
187
|
-
>>> basemap = Basemap.get_basemap(client, name='test')
|
|
188
|
-
or
|
|
189
|
-
>>> basemap = client.get_basemap(name='test')
|
|
190
|
-
>>> async with AsyncGeoboxClient() as async_client:
|
|
191
|
-
>>> async_basemap = basemap.to_async(async_client)
|
|
192
|
-
"""
|
|
193
|
-
from .aio.basemap import
|
|
194
|
-
|
|
1
|
+
from typing import List, Dict, Optional, TYPE_CHECKING
|
|
2
|
+
from urllib.parse import urljoin, urlencode
|
|
3
|
+
|
|
4
|
+
from .base import Base
|
|
5
|
+
from .exception import NotFoundError
|
|
6
|
+
from .utils import clean_data
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from . import GeoboxClient
|
|
10
|
+
from .aio import AsyncGeoboxClient
|
|
11
|
+
from .aio.basemap import AsyncBasemap
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Basemap(Base):
|
|
15
|
+
|
|
16
|
+
BASE_ENDPOINT = 'basemaps/'
|
|
17
|
+
|
|
18
|
+
def __init__(self,
|
|
19
|
+
api: 'GeoboxClient',
|
|
20
|
+
data: Optional[Dict] = {}):
|
|
21
|
+
"""
|
|
22
|
+
Initialize a basemap instance.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
api (GeoboxClient): The GeoboxClient 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
|
+
def get_basemaps(cls, api: 'GeoboxClient') -> List['Basemap']:
|
|
34
|
+
"""
|
|
35
|
+
Get a list of basemaps
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
List[BaseMap]: list of basemaps.
|
|
42
|
+
|
|
43
|
+
Example:
|
|
44
|
+
>>> from geobox import GeoboxClient
|
|
45
|
+
>>> from geobox.basemap import Basemap
|
|
46
|
+
>>> client = GeoboxClient()
|
|
47
|
+
>>> basemaps = Basemap.get_basemaps(client)
|
|
48
|
+
or
|
|
49
|
+
>>> basemaps = client.get_basemaps()
|
|
50
|
+
"""
|
|
51
|
+
response = 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
|
+
def get_basemap(cls, api: 'GeoboxClient', name: str) -> 'Basemap':
|
|
65
|
+
"""
|
|
66
|
+
Get a basemap object
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
api (GeoboxClient): The GeoboxClient 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 import GeoboxClient
|
|
80
|
+
>>> from geobox.basemap import Basemap
|
|
81
|
+
>>> client = GeoboxClient()
|
|
82
|
+
>>> basemap = Basemap.get_basemap(client, name='test')
|
|
83
|
+
or
|
|
84
|
+
>>> basemap = client.get_basemap(name='test')
|
|
85
|
+
"""
|
|
86
|
+
basemap = [basemap for basemap in cls.get_basemaps(api) if basemap.name == name]
|
|
87
|
+
if not basemap:
|
|
88
|
+
raise NotFoundError(f'Basemap with name "{name}" not found.')
|
|
89
|
+
|
|
90
|
+
return basemap[0]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def thumbnail(self) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Get the thumbnail url of the basemap
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
str: the thumbnail url
|
|
100
|
+
"""
|
|
101
|
+
return super()._thumbnail()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def wmts(self) -> str:
|
|
106
|
+
"""
|
|
107
|
+
Get the wmts url of the basemap
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
str: the wmts url
|
|
111
|
+
"""
|
|
112
|
+
endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
|
|
113
|
+
|
|
114
|
+
if not self.api.access_token and self.api.apikey:
|
|
115
|
+
endpoint = f"{endpoint}?apikey={self.api.apikey}"
|
|
116
|
+
|
|
117
|
+
return endpoint
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def server_url(self) -> str:
|
|
122
|
+
"""
|
|
123
|
+
Get the server url of the basemap
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
str: the server url
|
|
127
|
+
"""
|
|
128
|
+
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}server_url'
|
|
129
|
+
return self.api.get(endpoint)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def proxy_url(self) -> str:
|
|
134
|
+
"""
|
|
135
|
+
Get the proxy url of the basemap
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
str: the proxy url
|
|
139
|
+
"""
|
|
140
|
+
endpoint = f'{self.api.base_url}{self.BASE_ENDPOINT}proxy_url'
|
|
141
|
+
return self.api.get(endpoint)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@classmethod
|
|
145
|
+
def proxy_basemap(cls, api: 'GeoboxClient', url: str) -> None:
|
|
146
|
+
"""
|
|
147
|
+
Proxy the basemap
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
151
|
+
url (str): the proxy server url.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
None
|
|
155
|
+
|
|
156
|
+
Example:
|
|
157
|
+
>>> from geobox import GeoboxClient
|
|
158
|
+
>>> from geobox.basemap import Basemap
|
|
159
|
+
>>> client = GeoboxClient()
|
|
160
|
+
>>> Basemap.proxy_basemap(client, url='proxy_server_url')
|
|
161
|
+
or
|
|
162
|
+
>>> client.proxy_basemap(url='proxy_server_url')
|
|
163
|
+
"""
|
|
164
|
+
param = clean_data({
|
|
165
|
+
'url': url
|
|
166
|
+
})
|
|
167
|
+
query_string = urlencode(param)
|
|
168
|
+
endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
|
|
169
|
+
api.get(endpoint)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncBasemap':
|
|
173
|
+
"""
|
|
174
|
+
Switch to async version of the basemap instance to have access to the async methods
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
AsyncBasemap: the async instance of the basemap.
|
|
181
|
+
|
|
182
|
+
Example:
|
|
183
|
+
>>> from geobox import Geoboxclient
|
|
184
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
185
|
+
>>> from geobox.basemap import Basemap
|
|
186
|
+
>>> client = GeoboxClient()
|
|
187
|
+
>>> basemap = Basemap.get_basemap(client, name='test')
|
|
188
|
+
or
|
|
189
|
+
>>> basemap = client.get_basemap(name='test')
|
|
190
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
191
|
+
>>> async_basemap = basemap.to_async(async_client)
|
|
192
|
+
"""
|
|
193
|
+
from .aio.basemap import AsyncBasemap
|
|
194
|
+
|
|
195
195
|
return AsyncBasemap(api=async_client, data=self.data)
|