geobox 1.3.2__py3-none-any.whl → 1.3.4__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/api.py CHANGED
@@ -781,16 +781,14 @@ class GeoboxClient:
781
781
  return VectorLayerView.get_view_by_name(self, name, user_id)
782
782
 
783
783
 
784
- def create_tileset(self, name: str, layers: List[Dict], display_name: str = None, description: str = None,
784
+ def create_tileset(self, name: str, layers: List[Union['VectorLayer', 'VectorLayerView']], display_name: str = None, description: str = None,
785
785
  min_zoom: int = None, max_zoom: int = None, user_id: int = None) -> 'Tileset':
786
786
  """
787
787
  Create a new tileset.
788
788
 
789
789
  Args:
790
790
  name (str): The name of the tileset.
791
- layers (List[Dict]): The layers of the tileset. a list of dictionaries with the following keys:
792
- - layer_type: The type of the layer. valid values are "vector" and "view".
793
- - layer_uuid: The uuid of the layer.
791
+ layers (List['VectorLayer' | 'VectorLayerView']): list of vectorlayer and view objects to add to tileset.
794
792
  display_name (str, optional): The display name of the tileset.
795
793
  description (str, optional): The description of the tileset.
796
794
  min_zoom (int, optional): The minimum zoom level of the tileset.
@@ -802,19 +800,16 @@ class GeoboxClient:
802
800
 
803
801
  Example:
804
802
  >>> from geobox import GeoboxClient
803
+ >>> from geobox.tileset import Tileset
805
804
  >>> client = GeoboxClient()
806
- >>> layers = [
807
- ... {
808
- ... "layer_type": "vector",
809
- ... "layer_uuid": "12345678-1234-5678-1234-567812345678"
810
- ... }
811
- ... ]
805
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
806
+ >>> view = client.get_view(uuid="12345678-1234-5678-1234-567812345678")
812
807
  >>> tileset = client.create_tileset(name="your_tileset_name",
813
808
  ... display_name="Your Tileset",
814
809
  ... description="Your description",
815
810
  ... min_zoom=0,
816
811
  ... max_zoom=14,
817
- ... layers=layers)
812
+ ... layers=[layer, view])
818
813
  """
819
814
  return Tileset.create_tileset(api=self,
820
815
  name=name,
geobox/attachment.py CHANGED
@@ -31,7 +31,7 @@ class Attachment(Base):
31
31
  """
32
32
  super().__init__(api, data=data)
33
33
  self.attachment_id = attachment_id
34
- self.endpoint = urljoin(self.BASE_ENDPOINT, str(self.attachment_id))
34
+ self.endpoint = f"{self.BASE_ENDPOINT}{str(self.attachment_id)}/"
35
35
 
36
36
 
37
37
  def __repr__(self) -> str:
@@ -293,6 +293,5 @@ class Attachment(Base):
293
293
  >>> attachment.thumbnail
294
294
  'https://example.com/thumbnail.png'
295
295
  """
296
- endpoint = f"{self.api.base_url}{self.endpoint}thumbnail"
297
- return endpoint
296
+ return super().thumbnail(format='')
298
297
 
geobox/base.py CHANGED
@@ -362,3 +362,24 @@ class Base:
362
362
 
363
363
  # If all parsing fails, return the original string
364
364
  return date_string
365
+
366
+
367
+ def thumbnail(self, format='.png') -> str:
368
+ """
369
+ Get the thumbnail URL of the resource.
370
+
371
+ Returns:
372
+ str: The thumbnail URL
373
+
374
+ Raises:
375
+ ValueError:
376
+ """
377
+ endpoint = f'{self.api.base_url}{self.endpoint}thumbnail{format}'
378
+
379
+ if not self.api.access_token and self.api.apikey:
380
+ endpoint = f'{endpoint}?apikey={self.api.apikey}'
381
+
382
+ elif not self.api.access_token and not self.api.apikey:
383
+ raise ValueError("either access_token or apikey must be available for this action.")
384
+
385
+ return endpoint
geobox/basemap.py CHANGED
@@ -23,7 +23,7 @@ class Basemap(Base):
23
23
  data (Dict): The data of the basemap.
24
24
  """
25
25
  super().__init__(api, data=data)
26
- self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}"
26
+ self.endpoint = f"{self.BASE_ENDPOINT}{self.data.get('name')}/"
27
27
 
28
28
 
29
29
  @classmethod
@@ -107,7 +107,11 @@ class Basemap(Base):
107
107
  Returns:
108
108
  str: the wmts url
109
109
  """
110
- endpoint = f"{self.api.base_url}{self.endpoint}/wmts"
110
+ endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
111
+
112
+ if not self.api.access_token and self.api.apikey:
113
+ endpoint = f"{endpoint}?apikey={self.api.apikey}"
114
+
111
115
  return endpoint
112
116
 
113
117
 
geobox/dashboard.py CHANGED
@@ -243,8 +243,7 @@ class Dashboard(Base):
243
243
  >>> dashboard.thumbnail
244
244
  'https://example.com/thumbnail.png'
245
245
  """
246
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}thumbnail.png')
247
- return endpoint
246
+ return super().thumbnail()
248
247
 
249
248
 
250
249
  def share(self, users: List['User']) -> None:
geobox/enums.py CHANGED
@@ -326,12 +326,6 @@ class QueryResultType(Enum):
326
326
  both = "both"
327
327
 
328
328
 
329
- class TilesetLayerType(Enum):
330
- Vector = "vector"
331
-
332
- View = "view"
333
-
334
-
335
329
  class FileOutputFormat(Enum):
336
330
  Shapefile = "Shapefile"
337
331
 
geobox/map.py CHANGED
@@ -2,7 +2,7 @@ from typing import Dict, List, Optional, Union, TYPE_CHECKING
2
2
  from urllib.parse import urljoin, urlencode
3
3
 
4
4
  from .base import Base
5
- from .utils import clean_data
5
+ from .utils import clean_data, join_url_params
6
6
  from .model3d import Model
7
7
 
8
8
  if TYPE_CHECKING:
@@ -276,8 +276,7 @@ class Map(Base):
276
276
  >>> map.thumbnail
277
277
  'https://example.com/thumbnail.png'
278
278
  """
279
- endpoint = f"{self.api.base_url}{self.endpoint}thumbnail.png"
280
- return endpoint
279
+ return super().thumbnail()
281
280
 
282
281
 
283
282
  def set_readonly(self, readonly: bool) -> None:
@@ -351,6 +350,10 @@ class Map(Base):
351
350
  endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
352
351
  if scale:
353
352
  endpoint = f"{endpoint}?scale={scale}"
353
+
354
+ if not self.api.access_token and self.api.apikey:
355
+ endpoint = join_url_params(endpoint, {"apikey": self.api.apikey})
356
+
354
357
  return endpoint
355
358
 
356
359
 
geobox/model3d.py CHANGED
@@ -258,11 +258,7 @@ class Model(Base):
258
258
  >>> model = Model.get_model(api=client, uuid="12345678-1234-5678-1234-567812345678")
259
259
  >>> model.thumbnail
260
260
  """
261
- if not self.uuid:
262
- raise ValueError("Model UUID is required.")
263
-
264
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}/thumbnail.png')
265
- return endpoint
261
+ return super().thumbnail()
266
262
 
267
263
 
268
264
  def share(self, users: List['User']) -> None:
geobox/mosaic.py CHANGED
@@ -295,14 +295,14 @@ class Mosaic(Raster):
295
295
  return super().get_point(lat, lng)
296
296
 
297
297
 
298
- def get_render_png_url(self, x: int, y: int, z: int, **kwargs) -> str:
298
+ def get_render_png_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}', **kwargs) -> str:
299
299
  """
300
300
  Get the tile render URL of the mosaic.
301
301
 
302
302
  Args:
303
- x (int): The x coordinate of the tile.
304
- y (int): The y coordinate of the tile.
305
- z (int): The zoom level of the tile.
303
+ x (int, optional): The x coordinate of the tile.
304
+ y (int, optional): The y coordinate of the tile.
305
+ z (int, optional): The zoom level of the tile.
306
306
 
307
307
  Keyword Args:
308
308
  indexes (str, optional): list of comma separated band indexes to be rendered. e.g. 1, 2, 3
@@ -326,14 +326,14 @@ class Mosaic(Raster):
326
326
  return super().get_render_png_url(x, y, z, **kwargs)
327
327
 
328
328
 
329
- def get_tile_png_url(self, x: int, y: int, z: int) -> str:
329
+ def get_tile_png_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}') -> str:
330
330
  """
331
331
  Get the tile PNG URL of the mosaic.
332
332
 
333
333
  Args:
334
- x (int): The x coordinate of the tile.
335
- y (int): The y coordinate of the tile.
336
- z (int): The zoom level of the tile.
334
+ x (int, optional): The x coordinate of the tile.
335
+ y (int, optional): The y coordinate of the tile.
336
+ z (int, optional): The zoom level of the tile.
337
337
 
338
338
  Returns:
339
339
  str: The tile PNG URL of the mosaic.
geobox/query.py CHANGED
@@ -620,22 +620,19 @@ class Query(Base):
620
620
  str: The thumbnail URL.
621
621
  """
622
622
  self._check_access()
623
- endpoint = f'{self.api.base_url}{self.endpoint}thumbnail.png'
624
- return endpoint
623
+ return super().thumbnail()
625
624
 
626
625
 
627
- def save_as_layer(self, layer_name: str, layer_type: 'QueryGeometryType') -> Dict:
626
+ def save_as_layer(self, layer_name: str, layer_type: 'QueryGeometryType' = None) -> Task:
628
627
  """
629
628
  Saves the query as a new layer.
630
629
 
631
630
  Args:
632
- sql (str): The SQL statement for the query.
633
- params (list): The parameters for the SQL statement.
634
631
  layer_name (str): The name of the new layer.
635
- layer_type (QueryGeometryType): The type of the new layer.
632
+ layer_type (QueryGeometryType, optional): The type of the new layer.
636
633
 
637
634
  Returns:
638
- Dict: The response from the API.
635
+ Task: The response task object.
639
636
 
640
637
  Raises:
641
638
  PermissionError: If the query is a read-only system query.
@@ -645,7 +642,7 @@ class Query(Base):
645
642
  >>> from geobox.query import Query
646
643
  >>> client = GeoboxClient()
647
644
  >>> query = Query.get_query(client, uuid="12345678-1234-5678-1234-567812345678")
648
- >>> query.save_as_layer(layer_name='test', layer_type=QueryGeometryType.POLYGON)
645
+ >>> query.save_as_layer(layer_name='test')
649
646
  """
650
647
  self._check_access()
651
648
 
@@ -659,7 +656,7 @@ class Query(Base):
659
656
  "sql": self.sql,
660
657
  "params": params,
661
658
  "layer_name": layer_name,
662
- "layer_type": layer_type.value
659
+ "layer_type": layer_type.value if layer_type else None
663
660
  })
664
661
 
665
662
  endpoint = urljoin(self.BASE_ENDPOINT, 'saveAsLayer/')
geobox/raster.py CHANGED
@@ -6,7 +6,7 @@ import requests
6
6
  import sys
7
7
 
8
8
  from .base import Base
9
- from .utils import clean_data
9
+ from .utils import clean_data, join_url_params
10
10
  from .task import Task
11
11
 
12
12
  if TYPE_CHECKING:
@@ -231,8 +231,7 @@ class Raster(Base):
231
231
  >>> raster = Raster.get_raster(client, uuid="12345678-1234-5678-1234-567812345678")
232
232
  >>> raster.thumbnail
233
233
  """
234
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}thumbnail/')
235
- return endpoint
234
+ return super().thumbnail(format='')
236
235
 
237
236
 
238
237
  @property
@@ -511,19 +510,20 @@ class Raster(Base):
511
510
  'colormap': kwargs.get('colormap')
512
511
  })
513
512
  query_string = urlencode(params)
514
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}render/{z}/{x}/{y}.png')
515
- endpoint = urljoin(endpoint, f'?{query_string}')
513
+ endpoint = f'{self.api.base_url}{self.endpoint}render/{z}/{x}/{y}.png'
514
+ if query_string:
515
+ endpoint = f'{endpoint}?{query_string}'
516
516
  return endpoint
517
517
 
518
518
 
519
- def get_tile_pbf_url(self, x: int, y: int, z: int, indexes: str = None) -> str:
519
+ def get_tile_pbf_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}', indexes: str = None) -> str:
520
520
  """
521
521
  Get the URL of the tile.
522
522
 
523
523
  Args:
524
- x (int): The x coordinate of the tile.
525
- y (int): The y coordinate of the tile.
526
- z (int): The zoom level of the tile.
524
+ x (int, optional): The x coordinate of the tile.
525
+ y (int, optional): The y coordinate of the tile.
526
+ z (int, optional): The zoom level of the tile.
527
527
  indexes (str, optional): list of comma separated band indexes to be rendered. e.g. 1, 2, 3
528
528
 
529
529
  Returns:
@@ -542,17 +542,21 @@ class Raster(Base):
542
542
  query_string = urlencode(params)
543
543
  endpoint = urljoin(self.api.base_url, f'{self.endpoint}tiles/{z}/{x}/{y}.pbf')
544
544
  endpoint = urljoin(endpoint, f'?{query_string}')
545
+
546
+ if not self.api.access_token and self.api.apikey:
547
+ endpoint = join_url_params(endpoint, {"apikey": self.api.apikey})
548
+
545
549
  return endpoint
546
550
 
547
551
 
548
- def get_tile_png_url(self, x: int, y: int, z: int) -> str:
552
+ def get_tile_png_url(self, x: int = 'x', y: int = 'y', z: int = 'z') -> str:
549
553
  """
550
554
  Get the URL of the tile.
551
555
 
552
556
  Args:
553
- x (int): The x coordinate of the tile.
554
- y (int): The y coordinate of the tile.
555
- z (int): The zoom level of the tile.
557
+ x (int, optional): The x coordinate of the tile.
558
+ y (int, optional): The y coordinate of the tile.
559
+ z (int, optional): The zoom level of the tile.
556
560
 
557
561
  Returns:
558
562
  str: The URL of the tile.
@@ -564,7 +568,11 @@ class Raster(Base):
564
568
  >>> raster = Raster.get_raster(client, uuid="12345678-1234-5678-1234-567812345678")
565
569
  >>> raster.get_tile_png_url(x=10, y=20, z=1)
566
570
  """
567
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}tiles/{z}/{x}/{y}.png')
571
+ endpoint = f'{self.api.base_url}{self.endpoint}tiles/{z}/{x}/{y}.png'
572
+
573
+ if not self.api.access_token and self.api.apikey:
574
+ endpoint = f'{endpoint}?apikey={self.api.apikey}'
575
+
568
576
  return endpoint
569
577
 
570
578
 
@@ -606,6 +614,10 @@ class Raster(Base):
606
614
  endpoint = urljoin(self.api.base_url, f'{self.endpoint}wmts/')
607
615
  if scale:
608
616
  endpoint = f"{endpoint}?scale={scale}"
617
+
618
+ if not self.api.access_token and self.api.apikey:
619
+ endpoint = join_url_params(endpoint, {"apikey": self.api.apikey})
620
+
609
621
  return endpoint
610
622
 
611
623
 
geobox/scene.py CHANGED
@@ -244,8 +244,7 @@ class Scene(Base):
244
244
  >>> scene.thumbnail
245
245
  'https://example.com/thumbnail.png'
246
246
  """
247
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}thumbnail.png')
248
- return endpoint
247
+ return super().thumbnail()
249
248
 
250
249
 
251
250
  def share(self, users: List['User']) -> None:
geobox/tile3d.py CHANGED
@@ -1,10 +1,10 @@
1
1
  from typing import List, Dict, Optional, TYPE_CHECKING, Union
2
- from urllib.parse import urljoin
3
2
 
4
3
  from .base import Base
5
4
 
6
5
  if TYPE_CHECKING:
7
6
  from . import GeoboxClient
7
+ from .user import User
8
8
 
9
9
 
10
10
  class Tile3d(Base):
@@ -199,8 +199,7 @@ class Tile3d(Base):
199
199
  >>> tile.thumbnail
200
200
  'https://example.com/thumbnail.png'
201
201
  """
202
- endpoint = urljoin(self.api.base_url, f'{self.endpoint}thumbnail.png')
203
- return endpoint
202
+ return super().thumbnail()
204
203
 
205
204
 
206
205
  def get_item(self, path: str) -> Dict:
geobox/tileset.py CHANGED
@@ -3,8 +3,8 @@ from typing import Dict, List, Optional, Union, TYPE_CHECKING
3
3
 
4
4
  from .base import Base
5
5
  from .vectorlayer import VectorLayer
6
+ from .view import VectorLayerView
6
7
  from .task import Task
7
- from .enums import TilesetLayerType
8
8
 
9
9
  if TYPE_CHECKING:
10
10
  from . import GeoboxClient
@@ -35,7 +35,7 @@ class Tileset(Base):
35
35
 
36
36
 
37
37
  @classmethod
38
- def create_tileset(cls, api: 'GeoboxClient', name: str, layers: List[Dict], display_name: str = None, description: str = None,
38
+ def create_tileset(cls, api: 'GeoboxClient', name: str, layers: List[Union['VectorLayer', 'VectorLayerView']], display_name: str = None, description: str = None,
39
39
  min_zoom: int = None, max_zoom: int = None, user_id: int = None) -> 'Tileset':
40
40
  """
41
41
  Create a new tileset.
@@ -43,9 +43,7 @@ class Tileset(Base):
43
43
  Args:
44
44
  api (GeoboxClient): The GeoboxClient instance for making requests.
45
45
  name (str): The name of the tileset.
46
- layers (List[Dict]): The layers of the tileset. a list of dictionaries with the following keys:
47
- - layer_type: The type of the layer. valid values are "vector" and "view".
48
- - layer_uuid: The uuid of the layer.
46
+ layers (List[VectorLayer | VectorLayerView]): list of vectorlayer and view objects to add to tileset.
49
47
  display_name (str, optional): The display name of the tileset.
50
48
  description (str, optional): The description of the tileset.
51
49
  min_zoom (int, optional): The minimum zoom level of the tileset.
@@ -59,34 +57,46 @@ class Tileset(Base):
59
57
  >>> from geobox import GeoboxClient
60
58
  >>> from geobox.tileset import Tileset
61
59
  >>> client = GeoboxClient()
62
- >>> layers = [
63
- ... {
64
- ... "layer_type": "vector",
65
- ... "layer_uuid": "12345678-1234-5678-1234-567812345678"
66
- ... }
67
- ... ]
60
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
61
+ >>> view = client.get_view(uuid="12345678-1234-5678-1234-567812345678")
68
62
  >>> tileset = Tileset.create_tileset(client,
69
63
  ... name="your_tileset_name",
70
64
  ... display_name="Your Tileset",
71
65
  ... description="Your description",
72
66
  ... min_zoom=0,
73
67
  ... max_zoom=14,
74
- ... layers=layers)
68
+ ... layers=[layer, view])
75
69
  or
76
70
  >>> tileset = client.create_tileset(name="your_tileset_name",
77
71
  ... display_name="Your Tileset",
78
72
  ... description="Your description",
79
73
  ... min_zoom=0,
80
74
  ... max_zoom=14,
81
- ... layers=layers)
75
+ ... layers=[layer, view])
82
76
  """
77
+ formatted_layers = []
78
+ for item in layers:
79
+ if type(item) == VectorLayer:
80
+ item_type = 'vector'
81
+
82
+ elif type(item) == VectorLayerView:
83
+ item_type = 'view'
84
+
85
+ else:
86
+ continue
87
+
88
+ formatted_layers.append({
89
+ 'layer_type': item_type,
90
+ 'layer_uuid': item.uuid
91
+ })
92
+
83
93
  data = {
84
94
  "name": name,
85
95
  "display_name": display_name,
86
96
  "description": description,
87
97
  "min_zoom": min_zoom,
88
98
  "max_zoom": max_zoom,
89
- "layers": layers,
99
+ "layers": formatted_layers,
90
100
  "user_id": user_id
91
101
  }
92
102
  return super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: Tileset(api, item['uuid'], item))
@@ -283,7 +293,7 @@ class Tileset(Base):
283
293
  super().delete(urljoin(self.BASE_ENDPOINT, f'{self.uuid}/'))
284
294
 
285
295
 
286
- def get_tileset_layers(self, **kwargs) -> List['VectorLayer']:
296
+ def get_layers(self, **kwargs) -> List['VectorLayer']:
287
297
  """
288
298
  Retrieves the layers of the tileset with optional parameters.
289
299
 
@@ -307,13 +317,14 @@ class Tileset(Base):
307
317
  Example:
308
318
 
309
319
  Returns:
310
- List: A list of VectorLayer instances.
320
+ List: A list of VectorLayer or VectorLayerView instances.
311
321
 
312
322
  Example:
313
323
  >>> from geobox import GeoboxClient
314
324
  >>> from geobox.tileset import Tileset
315
325
  >>> client = GeoboxClient()
316
- >>> tilesets = Tileset.get_tileset_layers()
326
+ >>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
327
+ >>> layers = tileset.get_layers()
317
328
  """
318
329
  params = {
319
330
  'f': 'json',
@@ -328,57 +339,82 @@ class Tileset(Base):
328
339
  'shared': kwargs.get('shared', False)
329
340
  }
330
341
  endpoint = urljoin(self.BASE_ENDPOINT, f'{self.uuid}/layers/')
331
- return super()._get_list(self.api, endpoint, params, factory_func=lambda api, item: VectorLayer(api, item['uuid'], item['layer_type'], item))
342
+ return super()._get_list(self.api, endpoint, params, factory_func=lambda api, item: VectorLayer(api, item['uuid'], item['layer_type'], item) if not item['is_view'] else \
343
+ VectorLayerView(api, item['uuid'], item['layer_type'], item) )
332
344
 
333
345
 
334
- def add_layer(self, layer_type: TilesetLayerType, layer_uuid: str) -> None:
346
+ def add_layer(self, layer: Union['VectorLayer', 'VectorLayerView']) -> None:
335
347
  """
336
348
  Adds a layer to the tileset.
337
349
 
338
350
  Args:
339
- layer_type (TilesetLayerType): The type of the layer. "vector" or "view".
340
- layer_uuid (str): The UUID of the layer.
351
+ layer (VectorLayer | VectorLayerView): the layer object to add to the tileset
341
352
 
342
353
  Returns:
343
354
  None
344
355
 
356
+ Raises:
357
+ ValueError: if the layer input is not a 'VectorLayer' or 'VetorLayerview' object
358
+
345
359
  Example:
346
360
  >>> from geobox import GeoboxClient
347
361
  >>> from geobox.tileset import Tileset
348
362
  >>> client = GeoboxClient()
349
363
  >>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
350
- >>> tileset.add_layer_tileset(layer_type=TilesetLayerType.Vector, layer_uuid="12345678-1234-5678-1234-567812345678")
364
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
365
+ >>> tileset.add_layer(layer)
351
366
  """
367
+ if type(layer) == VectorLayer:
368
+ layer_type = 'vector'
369
+
370
+ elif type(layer) == VectorLayerView:
371
+ layer_type = 'view'
372
+
373
+ else:
374
+ raise ValueError("layer input must be either 'VectorLayer' or 'VetorLayerview' object")
375
+
352
376
  data = {
353
- "layer_type": layer_type.value,
354
- "layer_uuid": layer_uuid
377
+ "layer_type": layer_type,
378
+ "layer_uuid": layer.uuid
355
379
  }
356
380
 
357
381
  endpoint = urljoin(self.endpoint, 'layers/')
358
382
  return self.api.post(endpoint, data, is_json=False)
359
383
 
360
384
 
361
- def delete_layer(self, layer_type: TilesetLayerType, layer_uuid: str) -> None:
385
+ def delete_layer(self, layer: Union['VectorLayer', 'VectorLayerView']) -> None:
362
386
  """
363
387
  Deletes a layer from the tileset.
364
388
 
365
389
  Args:
366
- layer_type (TilesetLayerType): The type of the layer. "vector" or "view".
367
- layer_uuid (str): The UUID of the layer.
390
+ layer (VectorLayer | VectorLayerView): the layer object to delete from the tileset
368
391
 
369
392
  Returns:
370
393
  None
371
394
 
395
+ Raises:
396
+ ValueError: if the layer input is not a 'VectorLayer' or 'VetorLayerview' object
397
+
372
398
  Example:
373
399
  >>> from geobox import GeoboxClient
374
400
  >>> from geobox.tileset import Tileset
375
401
  >>> client = GeoboxClient()
376
402
  >>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
377
- >>> tileset.delete_layer_tileset(layer_type=TilesetLayerType.Vector, layer_uuid="12345678-1234-5678-1234-567812345678")
403
+ >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
404
+ >>> tileset.delete_layer(layer)
378
405
  """
406
+ if type(layer) == VectorLayer:
407
+ layer_type = 'vector'
408
+
409
+ elif type(layer) == VectorLayerView:
410
+ layer_type = 'view'
411
+
412
+ else:
413
+ raise ValueError("layer input must be either 'VectorLayer' or 'VetorLayerview' object")
414
+
379
415
  data = {
380
- "layer_type": layer_type.value,
381
- "layer_uuid": layer_uuid
416
+ "layer_type": layer_type,
417
+ "layer_uuid": layer.uuid
382
418
  }
383
419
 
384
420
  endpoint = urljoin(self.endpoint, 'layers/')
@@ -490,14 +526,14 @@ class Tileset(Base):
490
526
  return self.api.post(endpoint)
491
527
 
492
528
 
493
- def get_tile(self, x: int, y: int, z: int) -> str:
529
+ def get_tile_pbf_url(self, x: 'int' = '{x}', y: int = '{y}', z: int = '{z}') -> str:
494
530
  """
495
531
  Retrieves a tile from the tileset.
496
532
 
497
533
  Args:
498
- x (int): The x coordinate of the tile.
499
- y (int): The y coordinate of the tile.
500
- z (int): The zoom level of the tile.
534
+ x (int, optional): The x coordinate of the tile.
535
+ y (int, optioanl): The y coordinate of the tile.
536
+ z (int, optional): The zoom level of the tile.
501
537
 
502
538
  Returns:
503
539
  str: The url of the tile.
@@ -509,7 +545,11 @@ class Tileset(Base):
509
545
  >>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
510
546
  >>> tileset.get_tile_tileset(x=1, y=1, z=1)
511
547
  """
512
- endpoint = urljoin(self.endpoint, f'tiles/{z}/{x}/{y}.pbf')
548
+ endpoint = f'{self.api.base_url}{self.endpoint}tiles/{z}/{x}/{y}.pbf'
549
+
550
+ if not self.api.access_token and self.api.apikey:
551
+ endpoint = f'{endpoint}?apikey={self.api.apikey}'
552
+
513
553
  return endpoint
514
554
 
515
555
 
@@ -525,7 +565,7 @@ class Tileset(Base):
525
565
  user_id (int, optional): The user ID.
526
566
 
527
567
  Returns:
528
- List[Task]: The task object.
568
+ List[Task]: list of task objects.
529
569
 
530
570
  Raises:
531
571
  ValueError: If the number of workers is not one of the following: 1, 2, 4, 8, 12, 16, 20, 24.
@@ -547,14 +587,26 @@ class Tileset(Base):
547
587
  return super()._seed_cache(endpoint=self.endpoint, data=data)
548
588
 
549
589
 
550
- def update_cache(self) -> List['Task']:
590
+ def update_cache(self, from_zoom: int, to_zoom: int, extents: List[List[float]] = None, user_id: int = 0) -> List['Task']:
551
591
  """
552
592
  Updates the cache of the tileset.
553
593
 
594
+ Args:
595
+ from_zoom (int): The starting zoom level.
596
+ to_zoom (int): The ending zoom level.
597
+ extents (List[List[float]], optional): The list of extents to update the cache for.
598
+ user_id (int, optional): The user ID.
599
+
554
600
  Returns:
555
- None
601
+ List[Task]: list of task objects.
556
602
  """
557
- return super()._update_cache(endpoint=self.endpoint)
603
+ data = {
604
+ "from_zoom": from_zoom,
605
+ "to_zoom": to_zoom,
606
+ "extents": extents,
607
+ "user_id": user_id
608
+ }
609
+ return super()._update_cache(endpoint=self.endpoint, data=data)
558
610
 
559
611
 
560
612
  @property
geobox/vectorlayer.py CHANGED
@@ -1000,17 +1000,17 @@ class VectorLayer(Base):
1000
1000
  factory_func=lambda api, item: VectorLayerView(api, item['uuid'], self.layer_type, item))
1001
1001
 
1002
1002
 
1003
- def get_tile(self, x: int, y: int, z: int) -> str:
1003
+ def get_tile_pbf_url(self, x: int = '{x}', y: int = '{y}', z: int = '{z}') -> str:
1004
1004
  """
1005
1005
  Get a vector tile for the layer.
1006
1006
 
1007
1007
  Args:
1008
- x (int): X coordinate of the tile.
1009
- y (int): Y coordinate of the tile.
1010
- z (int): Zoom level of the tile.
1008
+ x (int, optional): X coordinate of the tile.
1009
+ y (int, optional): Y coordinate of the tile.
1010
+ z (int, optioanl): Zoom level of the tile.
1011
1011
 
1012
1012
  Returns:
1013
- str: The vector tile data.
1013
+ str: The vector tile url.
1014
1014
 
1015
1015
  Example:
1016
1016
  >>> from geobox import GeoboxClient
@@ -1019,7 +1019,11 @@ class VectorLayer(Base):
1019
1019
  >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678")
1020
1020
  >>> tile = layer.get_tile(x=10, y=20, z=1)
1021
1021
  """
1022
- endpoint = f'{self.BASE_ENDPOINT}{self.endpoint}tiles/{z}/{x}/{y}.pbf'
1022
+ endpoint = f'{self.api.base_url}{self.endpoint}tiles/{z}/{x}/{y}.pbf'
1023
+
1024
+ if not self.api.access_token and self.api.apikey:
1025
+ endpoint = f'{endpoint}?apikey={self.api.apikey}'
1026
+
1023
1027
  return endpoint
1024
1028
 
1025
1029
 
geobox/view.py CHANGED
@@ -663,7 +663,7 @@ class VectorLayerView(VectorLayer):
663
663
  bbox, out_srid, zipped, feature_ids, bbox_srid, q, fields)
664
664
 
665
665
 
666
- def get_tile(self, x: int, y: int, z: int) -> Dict:
666
+ def get_tile_pbf_url(self, x: int, y: int, z: int) -> str:
667
667
  """
668
668
  Get a vector tile for the layer.
669
669
 
@@ -673,7 +673,7 @@ class VectorLayerView(VectorLayer):
673
673
  z (int): Zoom level of the tile.
674
674
 
675
675
  Returns:
676
- Dict: The vector tile data.
676
+ str: the vector tile url.
677
677
 
678
678
  Example:
679
679
  >>> from geobox import GeoboxClient
@@ -682,7 +682,7 @@ class VectorLayerView(VectorLayer):
682
682
  >>> view = VectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
683
683
  >>> tile = view.get_tile(x=10, y=20, z=1)
684
684
  """
685
- return super().get_tile(x, y, z)
685
+ return super().get_tile_pbf_url(x, y, z)
686
686
 
687
687
 
688
688
  def get_tile_json(self) -> Dict:
geobox/workflow.py CHANGED
@@ -242,8 +242,7 @@ class Workflow(Base):
242
242
  >>> workflow.thumbnail
243
243
  'https://example.com/thumbnail.png'
244
244
  """
245
- endpoint = f"{self.api.base_url}{self.endpoint}thumbnail.png"
246
- return endpoint
245
+ return super().thumbnail()
247
246
 
248
247
 
249
248
  def share(self, users: List['User']) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 1.3.2
3
+ Version: 1.3.4
4
4
  Summary: SDK for Geobox's APIs
5
5
  Author-email: Hamid Heydari <heydari.h62@gmail.com>
6
6
  License: MIT
@@ -31,6 +31,8 @@ Geobox® is a cloud-based GIS platform that enables users (local governments, co
31
31
 
32
32
  Geobox python SDK provides seamless integration with the Geobox API, enabling developers to work with geospatial data and services programmatically. This comprehensive toolkit empowers applications to leverage advanced geospatial capabilities including data management and analysis.
33
33
 
34
+ [Here](https://geobox.readthedocs.io) you can find the official documentation for Geobox Python SDK.
35
+
34
36
  Installation
35
37
  ============
36
38
 
@@ -0,0 +1,37 @@
1
+ geobox/__init__.py,sha256=iRkJAFIjMXiAaLTVXvZcW5HM7ttyipGdxFZ15NCM8qU,1895
2
+ geobox/api.py,sha256=spbIWSeYCml_rmiisDLQjFcvm6I_UJGobUJm9H-Z9sQ,100719
3
+ geobox/apikey.py,sha256=FBio1PtGovAUaTE0HW9IJ55UuFdR_1ICk_FQhHu5dAE,7427
4
+ geobox/attachment.py,sha256=qplcYfHkoV9aHaXQ7xFnkrsYxwmUs0PNPbjoSerET34,11582
5
+ geobox/base.py,sha256=OdabLbBflglLkNWM7TGCWtPh73M_-42_Ph963K26JQg,12931
6
+ geobox/basemap.py,sha256=7Jo2MeEN8U8Av54kPPaFzQFjajcNYgMRMOTZXPUcXyk,4529
7
+ geobox/dashboard.py,sha256=x99jUGzUJra4cdcffSYC0_FvrihZh6sPI4o79f-Aptc,11694
8
+ geobox/enums.py,sha256=mGF6eXQlNHcUXV0AVMolI200a__g-S9wMjQ1p4ka28g,6244
9
+ geobox/exception.py,sha256=jvpnv0M2Ck1FpxHTL_aKYWxGvLnCQ3d9vOrMIktjw1U,1507
10
+ geobox/feature.py,sha256=3Kbc1LjIkBt1YqRAry84BrR7qxx9BexvBB3YQ8D9mGk,18504
11
+ geobox/field.py,sha256=p9eitUpnsiGj6GUhjSomk6HWlsNJSbE-Oh_4VcjaqVo,10562
12
+ geobox/file.py,sha256=Ula8r8pZaCmifsnUHDbaJujw53SLxUiCiBzVS358o88,19967
13
+ geobox/log.py,sha256=ZTmVErhyAszf7M5YFxT5mqXNNDGPnRwXPeGLDS1G6PE,3582
14
+ geobox/map.py,sha256=6pyD4rpw-Z9DIuvVg66UCBsPk30eCt0b1cIjVBxA_1Q,31348
15
+ geobox/model3d.py,sha256=8P7_Yj1JvumCHWqMxgUmIvQvsKs5tSjI1vf00AItyHQ,11901
16
+ geobox/mosaic.py,sha256=6wSK9xkjtBUEtIsZANWVYwsJbDx112mO1SQOXcPTVo8,23780
17
+ geobox/plan.py,sha256=_ZV9F6loG92uQZGJl_9T08Kg85g3hnODmpccSkTYVdw,11193
18
+ geobox/query.py,sha256=FqeiZf2E4tJ2FG-mIfRKov6H1QWUrMSErVpNWcb3Wx0,24038
19
+ geobox/raster.py,sha256=Gt2bHb8NYm-8JkJlFm4-VccihcfZQzhQA8hPc3xzfvI,29934
20
+ geobox/route.py,sha256=cKZTTHBHM8woWbhHIpCvrRX_doJcTkGktouee0z7oG0,2723
21
+ geobox/scene.py,sha256=GEzvWB-l-xO-8IodwFAPt4T7lZxuzEKJ1H0cqfx78W4,11301
22
+ geobox/settings.py,sha256=rGRdM18Vo7xnjfZXPLRMbKeoVC_lZmzkNRPS0SQv05o,5660
23
+ geobox/task.py,sha256=eLMgbhcYTADooWqKDPh6Jlh5S5oqxMMKoYIm0YPVZvg,13519
24
+ geobox/tile3d.py,sha256=5z6zOihHiwCDizP_9Zwsm87gkTMljm9rQ8hFpAUkA10,10398
25
+ geobox/tileset.py,sha256=bQOckE04F31vb-NYmNsQzXndZSTDZyskWspRikjZuBs,24241
26
+ geobox/usage.py,sha256=_54xL-n-2Bg9wGpoOBKnh85WqdpMWEtqxRJVaFlVWe0,7908
27
+ geobox/user.py,sha256=YY72uRvjKUUWUZbxhrft37FVBlqDeosPMf3EpMVBhc0,15069
28
+ geobox/utils.py,sha256=qLtchKIdw-az3KCiiFv0-Cpmx9RfBxORjlATvVyDIaQ,1314
29
+ geobox/vectorlayer.py,sha256=5IglRp7uoMm3yggYpHurDRAGQo9x7KdjJGicSLpxrSs,53035
30
+ geobox/version.py,sha256=0GLPhxCeEb2bAkdpPJWtXPXc1KP6kQ_TOMwLAL0ldo0,9374
31
+ geobox/view.py,sha256=ZNJNBQclM6fc0cxXmU_L_XEBwd4lbsEncs6ynxWU9lc,37531
32
+ geobox/workflow.py,sha256=7Ne_42-nG88_Po-OAK0ChWkfrknxJiPW6JFiElTwh3Q,11547
33
+ geobox-1.3.4.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
34
+ geobox-1.3.4.dist-info/METADATA,sha256=r4Bk6des4BDQI3KU3Kmt1rFhXQGSkYwiOVCgGRMvPPI,2658
35
+ geobox-1.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ geobox-1.3.4.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
37
+ geobox-1.3.4.dist-info/RECORD,,
@@ -1,37 +0,0 @@
1
- geobox/__init__.py,sha256=iRkJAFIjMXiAaLTVXvZcW5HM7ttyipGdxFZ15NCM8qU,1895
2
- geobox/api.py,sha256=v-_Vay_xIXZRG3-0ahiOWxVT9QkrIyuOcd2KYFyVK04,100795
3
- geobox/apikey.py,sha256=FBio1PtGovAUaTE0HW9IJ55UuFdR_1ICk_FQhHu5dAE,7427
4
- geobox/attachment.py,sha256=XbGwfWWuFAMimj4tsjKBvlSLP-rhpNACCtxgRmUvcdY,11631
5
- geobox/base.py,sha256=p0UVZo9CINw0mW9o0nNR_VNCk7V1r-FrLQ_NH39WARE,12299
6
- geobox/basemap.py,sha256=fDWwkMf-F2NTE1tVLijoxQku55825b6gj8nk69TMOII,4386
7
- geobox/dashboard.py,sha256=MYyT3YJEGPCbTXHcYoZmn14rFOaut1J3idEA8bCdFgI,11762
8
- geobox/enums.py,sha256=eYD-SVXCSp4l08DlxymJTqYzTLouRziWhLZd7letnTM,6317
9
- geobox/exception.py,sha256=jvpnv0M2Ck1FpxHTL_aKYWxGvLnCQ3d9vOrMIktjw1U,1507
10
- geobox/feature.py,sha256=3Kbc1LjIkBt1YqRAry84BrR7qxx9BexvBB3YQ8D9mGk,18504
11
- geobox/field.py,sha256=p9eitUpnsiGj6GUhjSomk6HWlsNJSbE-Oh_4VcjaqVo,10562
12
- geobox/file.py,sha256=Ula8r8pZaCmifsnUHDbaJujw53SLxUiCiBzVS358o88,19967
13
- geobox/log.py,sha256=ZTmVErhyAszf7M5YFxT5mqXNNDGPnRwXPeGLDS1G6PE,3582
14
- geobox/map.py,sha256=RjuhbOVQN-OBwjBtO46AosB_Ta348EA1nExBdnxH3nw,31252
15
- geobox/model3d.py,sha256=qRYCx-q9LpGhdu5oz3av0uUoiDimuk4BvXXwMW5bo9Q,12061
16
- geobox/mosaic.py,sha256=feBRsAgvhl0tKoghfZiQsxFntS7skAnzEYYuU4GKbP0,23672
17
- geobox/plan.py,sha256=_ZV9F6loG92uQZGJl_9T08Kg85g3hnODmpccSkTYVdw,11193
18
- geobox/query.py,sha256=KHUKx3vbdkwBQYsb9Lg9D3eHBEBFVVtqehqkd31mmjU,24216
19
- geobox/raster.py,sha256=ex2nUiMGwGN-9Zp3-Fotj9Z2noJRkyDf4-ZhwIponHw,29459
20
- geobox/route.py,sha256=cKZTTHBHM8woWbhHIpCvrRX_doJcTkGktouee0z7oG0,2723
21
- geobox/scene.py,sha256=Sz2tiyJk-bXYjktfcp1d2gGrW3gt2T4D1FAMoRHOCng,11369
22
- geobox/settings.py,sha256=rGRdM18Vo7xnjfZXPLRMbKeoVC_lZmzkNRPS0SQv05o,5660
23
- geobox/task.py,sha256=eLMgbhcYTADooWqKDPh6Jlh5S5oqxMMKoYIm0YPVZvg,13519
24
- geobox/tile3d.py,sha256=MHDoj2OIUf3VMQtq7ysrayh8njAPSgwgPJCm4ySEB7A,10472
25
- geobox/tileset.py,sha256=F_oEV0TERMc2seLcYNu-i_TF4MNSdXPUWcxBCSR8aFw,22242
26
- geobox/usage.py,sha256=_54xL-n-2Bg9wGpoOBKnh85WqdpMWEtqxRJVaFlVWe0,7908
27
- geobox/user.py,sha256=YY72uRvjKUUWUZbxhrft37FVBlqDeosPMf3EpMVBhc0,15069
28
- geobox/utils.py,sha256=qLtchKIdw-az3KCiiFv0-Cpmx9RfBxORjlATvVyDIaQ,1314
29
- geobox/vectorlayer.py,sha256=yK_5ZD7eBAbRV2ruZCMptCtNU-S0AMvsAFiGIcLf3LQ,52853
30
- geobox/version.py,sha256=0GLPhxCeEb2bAkdpPJWtXPXc1KP6kQ_TOMwLAL0ldo0,9374
31
- geobox/view.py,sha256=sIi6Mi7NUAX5gN83cpubD3l7AcZ-1g5kG2NKHeVeW-g,37518
32
- geobox/workflow.py,sha256=6hKnSw4G0_ZlgmUb0g3fxT-UVsFbiYpF2FbEO5fpQv0,11606
33
- geobox-1.3.2.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
34
- geobox-1.3.2.dist-info/METADATA,sha256=Upop-Ls1kfz5xjJKkxZ9WTKJqZEepRFc-4vptsZ7A70,2556
35
- geobox-1.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- geobox-1.3.2.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
37
- geobox-1.3.2.dist-info/RECORD,,
File without changes