geobox 1.3.3__tar.gz → 1.3.4__tar.gz

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 (69) hide show
  1. {geobox-1.3.3 → geobox-1.3.4}/PKG-INFO +3 -1
  2. {geobox-1.3.3 → geobox-1.3.4}/README.md +2 -0
  3. {geobox-1.3.3 → geobox-1.3.4}/geobox/attachment.py +2 -3
  4. {geobox-1.3.3 → geobox-1.3.4}/geobox/base.py +21 -0
  5. {geobox-1.3.3 → geobox-1.3.4}/geobox/basemap.py +6 -2
  6. {geobox-1.3.3 → geobox-1.3.4}/geobox/dashboard.py +1 -2
  7. {geobox-1.3.3 → geobox-1.3.4}/geobox/map.py +6 -3
  8. {geobox-1.3.3 → geobox-1.3.4}/geobox/model3d.py +1 -5
  9. {geobox-1.3.3 → geobox-1.3.4}/geobox/mosaic.py +8 -8
  10. {geobox-1.3.3 → geobox-1.3.4}/geobox/query.py +1 -2
  11. {geobox-1.3.3 → geobox-1.3.4}/geobox/raster.py +26 -14
  12. {geobox-1.3.3 → geobox-1.3.4}/geobox/scene.py +1 -2
  13. {geobox-1.3.3 → geobox-1.3.4}/geobox/tile3d.py +2 -3
  14. {geobox-1.3.3 → geobox-1.3.4}/geobox/tileset.py +26 -10
  15. {geobox-1.3.3 → geobox-1.3.4}/geobox/vectorlayer.py +10 -6
  16. {geobox-1.3.3 → geobox-1.3.4}/geobox/view.py +3 -3
  17. {geobox-1.3.3 → geobox-1.3.4}/geobox/workflow.py +1 -2
  18. {geobox-1.3.3 → geobox-1.3.4}/geobox.egg-info/PKG-INFO +3 -1
  19. {geobox-1.3.3 → geobox-1.3.4}/pyproject.toml +1 -1
  20. {geobox-1.3.3 → geobox-1.3.4}/tests/test_attachment.py +1 -1
  21. {geobox-1.3.3 → geobox-1.3.4}/tests/test_basemap.py +7 -2
  22. {geobox-1.3.3 → geobox-1.3.4}/tests/test_map.py +12 -1
  23. {geobox-1.3.3 → geobox-1.3.4}/tests/test_model3d.py +0 -4
  24. {geobox-1.3.3 → geobox-1.3.4}/tests/test_mosaic.py +1 -1
  25. {geobox-1.3.3 → geobox-1.3.4}/tests/test_raster.py +25 -3
  26. {geobox-1.3.3 → geobox-1.3.4}/tests/test_tileset.py +11 -7
  27. {geobox-1.3.3 → geobox-1.3.4}/tests/test_vectorlayer.py +8 -3
  28. {geobox-1.3.3 → geobox-1.3.4}/tests/test_view.py +3 -3
  29. {geobox-1.3.3 → geobox-1.3.4}/LICENSE +0 -0
  30. {geobox-1.3.3 → geobox-1.3.4}/geobox/__init__.py +0 -0
  31. {geobox-1.3.3 → geobox-1.3.4}/geobox/api.py +0 -0
  32. {geobox-1.3.3 → geobox-1.3.4}/geobox/apikey.py +0 -0
  33. {geobox-1.3.3 → geobox-1.3.4}/geobox/enums.py +0 -0
  34. {geobox-1.3.3 → geobox-1.3.4}/geobox/exception.py +0 -0
  35. {geobox-1.3.3 → geobox-1.3.4}/geobox/feature.py +0 -0
  36. {geobox-1.3.3 → geobox-1.3.4}/geobox/field.py +0 -0
  37. {geobox-1.3.3 → geobox-1.3.4}/geobox/file.py +0 -0
  38. {geobox-1.3.3 → geobox-1.3.4}/geobox/log.py +0 -0
  39. {geobox-1.3.3 → geobox-1.3.4}/geobox/plan.py +0 -0
  40. {geobox-1.3.3 → geobox-1.3.4}/geobox/route.py +0 -0
  41. {geobox-1.3.3 → geobox-1.3.4}/geobox/settings.py +0 -0
  42. {geobox-1.3.3 → geobox-1.3.4}/geobox/task.py +0 -0
  43. {geobox-1.3.3 → geobox-1.3.4}/geobox/usage.py +0 -0
  44. {geobox-1.3.3 → geobox-1.3.4}/geobox/user.py +0 -0
  45. {geobox-1.3.3 → geobox-1.3.4}/geobox/utils.py +0 -0
  46. {geobox-1.3.3 → geobox-1.3.4}/geobox/version.py +0 -0
  47. {geobox-1.3.3 → geobox-1.3.4}/geobox.egg-info/SOURCES.txt +0 -0
  48. {geobox-1.3.3 → geobox-1.3.4}/geobox.egg-info/dependency_links.txt +0 -0
  49. {geobox-1.3.3 → geobox-1.3.4}/geobox.egg-info/requires.txt +0 -0
  50. {geobox-1.3.3 → geobox-1.3.4}/geobox.egg-info/top_level.txt +0 -0
  51. {geobox-1.3.3 → geobox-1.3.4}/setup.cfg +0 -0
  52. {geobox-1.3.3 → geobox-1.3.4}/tests/test_api.py +0 -0
  53. {geobox-1.3.3 → geobox-1.3.4}/tests/test_apikey.py +0 -0
  54. {geobox-1.3.3 → geobox-1.3.4}/tests/test_dashboard.py +0 -0
  55. {geobox-1.3.3 → geobox-1.3.4}/tests/test_feature.py +0 -0
  56. {geobox-1.3.3 → geobox-1.3.4}/tests/test_field.py +0 -0
  57. {geobox-1.3.3 → geobox-1.3.4}/tests/test_file.py +0 -0
  58. {geobox-1.3.3 → geobox-1.3.4}/tests/test_log.py +0 -0
  59. {geobox-1.3.3 → geobox-1.3.4}/tests/test_plan.py +0 -0
  60. {geobox-1.3.3 → geobox-1.3.4}/tests/test_query.py +0 -0
  61. {geobox-1.3.3 → geobox-1.3.4}/tests/test_route.py +0 -0
  62. {geobox-1.3.3 → geobox-1.3.4}/tests/test_scene.py +0 -0
  63. {geobox-1.3.3 → geobox-1.3.4}/tests/test_settings.py +0 -0
  64. {geobox-1.3.3 → geobox-1.3.4}/tests/test_task.py +0 -0
  65. {geobox-1.3.3 → geobox-1.3.4}/tests/test_tile3d.py +0 -0
  66. {geobox-1.3.3 → geobox-1.3.4}/tests/test_usage.py +0 -0
  67. {geobox-1.3.3 → geobox-1.3.4}/tests/test_user.py +0 -0
  68. {geobox-1.3.3 → geobox-1.3.4}/tests/test_version.py +0 -0
  69. {geobox-1.3.3 → geobox-1.3.4}/tests/test_workflow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 1.3.3
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
 
@@ -5,6 +5,8 @@ Geobox® is a cloud-based GIS platform that enables users (local governments, co
5
5
 
6
6
  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.
7
7
 
8
+ [Here](https://geobox.readthedocs.io) you can find the official documentation for Geobox Python SDK.
9
+
8
10
  Installation
9
11
  ============
10
12
 
@@ -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
 
@@ -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
@@ -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
 
@@ -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:
@@ -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
 
@@ -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:
@@ -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.
@@ -620,8 +620,7 @@ 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
626
  def save_as_layer(self, layer_name: str, layer_type: 'QueryGeometryType' = None) -> Task:
@@ -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
 
@@ -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:
@@ -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:
@@ -43,7 +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['VectorLayer' | 'VectorLayerView']): list of vectorlayer and view objects to add to tileset.
46
+ layers (List[VectorLayer | VectorLayerView]): list of vectorlayer and view objects to add to tileset.
47
47
  display_name (str, optional): The display name of the tileset.
48
48
  description (str, optional): The description of the tileset.
49
49
  min_zoom (int, optional): The minimum zoom level of the tileset.
@@ -526,14 +526,14 @@ class Tileset(Base):
526
526
  return self.api.post(endpoint)
527
527
 
528
528
 
529
- 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:
530
530
  """
531
531
  Retrieves a tile from the tileset.
532
532
 
533
533
  Args:
534
- x (int): The x coordinate of the tile.
535
- y (int): The y coordinate of the tile.
536
- 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.
537
537
 
538
538
  Returns:
539
539
  str: The url of the tile.
@@ -545,7 +545,11 @@ class Tileset(Base):
545
545
  >>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
546
546
  >>> tileset.get_tile_tileset(x=1, y=1, z=1)
547
547
  """
548
- 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
+
549
553
  return endpoint
550
554
 
551
555
 
@@ -561,7 +565,7 @@ class Tileset(Base):
561
565
  user_id (int, optional): The user ID.
562
566
 
563
567
  Returns:
564
- List[Task]: The task object.
568
+ List[Task]: list of task objects.
565
569
 
566
570
  Raises:
567
571
  ValueError: If the number of workers is not one of the following: 1, 2, 4, 8, 12, 16, 20, 24.
@@ -583,14 +587,26 @@ class Tileset(Base):
583
587
  return super()._seed_cache(endpoint=self.endpoint, data=data)
584
588
 
585
589
 
586
- 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']:
587
591
  """
588
592
  Updates the cache of the tileset.
589
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
+
590
600
  Returns:
591
- None
601
+ List[Task]: list of task objects.
592
602
  """
593
- 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)
594
610
 
595
611
 
596
612
  @property
@@ -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
 
@@ -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:
@@ -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.3
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
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "geobox"
7
- version = "1.3.3"
7
+ version = "1.3.4"
8
8
  description = "SDK for Geobox's APIs"
9
9
  authors = [
10
10
  {name = "Hamid Heydari", email = "heydari.h62@gmail.com"}
@@ -13,7 +13,7 @@ def test_init(api, mock_attachment_data):
13
13
  assert attachment.name == mock_attachment_data['name']
14
14
  assert attachment.attachment_id == mock_attachment_data['id']
15
15
  assert attachment.data == mock_attachment_data
16
- assert attachment.endpoint == f'{Attachment.BASE_ENDPOINT}{attachment.attachment_id}'
16
+ assert attachment.endpoint == f'{Attachment.BASE_ENDPOINT}{attachment.attachment_id}/'
17
17
 
18
18
 
19
19
  def test_repr(api, mock_attachment_data):
@@ -10,7 +10,7 @@ def test_init(api, mock_basemap_data):
10
10
  basemap = Basemap(api, mock_basemap_data)
11
11
  assert basemap.name == mock_basemap_data['name']
12
12
  assert basemap.data == mock_basemap_data
13
- assert basemap.endpoint == f'{Basemap.BASE_ENDPOINT}{basemap.name}'
13
+ assert basemap.endpoint == f'{Basemap.BASE_ENDPOINT}{basemap.name}/'
14
14
 
15
15
 
16
16
  def test_get_basemaps(api, mock_basemap_data, mock_basemap_list_data):
@@ -48,7 +48,12 @@ def test_thumbnail(api, mock_basemap_data):
48
48
  def test_wmts(api, mock_basemap_data):
49
49
  basemap = Basemap(api, mock_basemap_data)
50
50
  wmts_url = basemap.wmts
51
- assert wmts_url == f"{api.base_url}{basemap.endpoint}/wmts"
51
+ assert wmts_url == f"{api.base_url}{basemap.endpoint}wmts/"
52
+ # apikey
53
+ api.access_token = ''
54
+ api.apikey = 'apikey_1234'
55
+ wmts_url = basemap.wmts
56
+ assert wmts_url == f"{api.base_url}{basemap.endpoint}wmts/?apikey=apikey_1234"
52
57
 
53
58
 
54
59
  def test_server_url(api, mock_basemap_data):
@@ -154,9 +154,15 @@ def test_style(api, mock_map_data):
154
154
 
155
155
 
156
156
  def test_thumbnail(api, mock_map_data):
157
+ api.access_token = ''
158
+ api.apikey = 'apikey_1234'
157
159
  map = Map(api, uuid=mock_map_data['uuid'], data=mock_map_data)
158
160
  thumbnail_url = map.thumbnail
159
- assert thumbnail_url == f'{api.base_url}{map.endpoint}thumbnail.png'
161
+ assert thumbnail_url == f'{api.base_url}{map.endpoint}thumbnail.png?apikey=apikey_1234'
162
+ # error
163
+ api.apikey = ''
164
+ with pytest.raises(ValueError):
165
+ map.thumbnail
160
166
 
161
167
 
162
168
  def test_set_readonly(api, mock_map_data):
@@ -183,6 +189,11 @@ def test_wmts(api, mock_map_data):
183
189
  map = Map(api, uuid=mock_map_data['uuid'], data=mock_map_data)
184
190
  wmts_url = map.wmts(scale=1)
185
191
  assert wmts_url == f'{api.base_url}{map.endpoint}wmts/?scale=1'
192
+ # apikey
193
+ api.access_token = ''
194
+ api.apikey = 'apikey_1234'
195
+ wmts_url = map.wmts(scale=1)
196
+ assert wmts_url == f"{api.base_url}{map.endpoint}wmts/?scale=1&apikey=apikey_1234"
186
197
 
187
198
 
188
199
  def test_share(api, mock_map_data, mock_user_data):
@@ -155,10 +155,6 @@ def test_get_content(api, mock_model_data):
155
155
  def test_thumbnail(api, mock_model_data):
156
156
  model = Model(api, uuid=mock_model_data['uuid'], data=mock_model_data)
157
157
  assert model.thumbnail == f"{api.base_url}{model.endpoint}thumbnail.png"
158
- # error
159
- model.uuid = None
160
- with pytest.raises(ValueError):
161
- model.thumbnail
162
158
 
163
159
 
164
160
  def test_share(api, mock_model_data, mock_user_data):
@@ -125,7 +125,7 @@ def test_thumbnail(api, mock_mosaic_data):
125
125
 
126
126
  thumbnail = mosaic.thumbnail
127
127
 
128
- assert thumbnail == f"{api.base_url}{mosaic.endpoint}thumbnail/"
128
+ assert thumbnail == f"{api.base_url}{mosaic.endpoint}thumbnail"
129
129
 
130
130
 
131
131
  def test_get_point(api, mock_mosaic_data):
@@ -119,7 +119,7 @@ def test_thumbnail(api, mock_raster_data):
119
119
  """Test getting raster thumbnail URL."""
120
120
  raster = Raster(api, uuid=mock_raster_data['uuid'], data=mock_raster_data)
121
121
  thumbnail_url = raster.thumbnail
122
- assert thumbnail_url == f"{api.base_url}{raster.endpoint}thumbnail/"
122
+ assert thumbnail_url == f"{api.base_url}{raster.endpoint}thumbnail"
123
123
 
124
124
 
125
125
  def test_raster_info(api, mock_raster_data):
@@ -247,8 +247,20 @@ def test_get_content(api, mock_raster_data):
247
247
  def test_get_render_png_url(api, mock_raster_data):
248
248
  """Test getting tile PNG URL."""
249
249
  raster = Raster(api, uuid=mock_raster_data['uuid'], data=mock_raster_data)
250
- url = raster.get_render_png_url(x=10, y=20, z=1)
251
- assert url == f"{raster.api.base_url}{raster.endpoint}render/1/10/20.png"
250
+ url = raster.get_render_png_url(x=10, y=20, z=1, indexes=1)
251
+ assert url == f"{raster.api.base_url}{raster.endpoint}render/1/10/20.png?indexes=1"
252
+
253
+
254
+ def test_get_tile_png_url(api, mock_raster_data):
255
+ """Test getting tile PNG URL."""
256
+ raster = Raster(api, uuid=mock_raster_data['uuid'], data=mock_raster_data)
257
+ url = raster.get_tile_png_url(x=10, y=20, z=1)
258
+ assert url == f"{raster.api.base_url}{raster.endpoint}tiles/1/10/20.png"
259
+ # apikey
260
+ api.access_token = ''
261
+ api.apikey = 'apikey_1234'
262
+ url = raster.get_tile_png_url(x=10, y=20, z=1)
263
+ assert url == f"{raster.api.base_url}{raster.endpoint}tiles/1/10/20.png?apikey=apikey_1234"
252
264
 
253
265
 
254
266
  def test_get_tile_pbf_url(api, mock_raster_data):
@@ -256,6 +268,11 @@ def test_get_tile_pbf_url(api, mock_raster_data):
256
268
  raster = Raster(api, uuid=mock_raster_data['uuid'], data=mock_raster_data)
257
269
  url = raster.get_tile_pbf_url(x=10, y=20, z=1)
258
270
  assert url == f"{raster.api.base_url}{raster.endpoint}tiles/1/10/20.pbf"
271
+ # apikey
272
+ api.access_token = ''
273
+ api.apikey = 'apikey_1234'
274
+ url = raster.get_tile_pbf_url(x=10, y=20, z=1)
275
+ assert url == f"{raster.api.base_url}{raster.endpoint}tiles/1/10/20.pbf?apikey=apikey_1234"
259
276
 
260
277
 
261
278
  def test_get_tile_json(api, mock_raster_data):
@@ -272,6 +289,11 @@ def test_wmts(api, mock_raster_data):
272
289
  raster = Raster(api, uuid=mock_raster_data['uuid'], data=mock_raster_data)
273
290
  url = raster.wmts(scale=1)
274
291
  assert url == f'{raster.api.base_url}{raster.endpoint}wmts/?scale=1'
292
+ # apikey
293
+ api.access_token = ''
294
+ api.apikey = 'apikey_1234'
295
+ url = raster.wmts(scale=1)
296
+ assert url == f'{raster.api.base_url}{raster.endpoint}wmts/?scale=1&apikey=apikey_1234'
275
297
 
276
298
 
277
299
  def test_settings(api, mock_raster_data):
@@ -273,12 +273,16 @@ def test_update_tileset_extent(api, mock_tileset_data):
273
273
  api.post.assert_called_once_with(endpoint)
274
274
 
275
275
 
276
- def test_get_tile(api, mock_tileset_data):
276
+ def test_get_tile_pbf_url(api, mock_tileset_data):
277
277
  """Test getting tile from tileset."""
278
- url = f"tilesets/{mock_tileset_data['uuid']}/tiles/1/1/1.pbf"
279
278
  tileset = Tileset(api, uuid=mock_tileset_data['uuid'], data=mock_tileset_data)
280
- tile_url = tileset.get_tile(x=1, y=1, z=1)
281
- assert tile_url == url
279
+ url = tileset.get_tile_pbf_url(x=1, y=1, z=1)
280
+ assert url == f"{api.base_url}{tileset.endpoint}tiles/1/1/1.pbf"
281
+ # apikey
282
+ api.access_token = ''
283
+ api.apikey = 'apikey_1234'
284
+ url = tileset.get_tile_pbf_url(x=1, y=1, z=1)
285
+ assert url == f"{api.base_url}{tileset.endpoint}tiles/1/1/1.pbf?apikey=apikey_1234"
282
286
 
283
287
 
284
288
  def test_seed_cache(api, mock_tileset_data, mock_success_task_data):
@@ -308,16 +312,16 @@ def test_update_cache(api, mock_tileset_data, mock_success_task_data):
308
312
 
309
313
  api.get.return_value = mock_success_task_data
310
314
 
311
- task = tileset.update_cache()[0]
315
+ task = tileset.update_cache(from_zoom=0, to_zoom=2, extents=[[1, 2, 3, 4]], user_id=1)[0]
312
316
  assert isinstance(task, Task)
313
- api.post.assert_called_once_with(f'{tileset.endpoint}cache/update/', {})
317
+ api.post.assert_called_once_with(f'{tileset.endpoint}cache/update/', {'from_zoom': 0, 'to_zoom': 2, 'extents': [[1, 2, 3, 4]], 'user_id': 1})
314
318
  # error
315
319
  api.post.return_value = [1, 2, 3]
316
320
 
317
321
  api.get.return_value = mock_success_task_data
318
322
 
319
323
  with pytest.raises(ValueError, match="Failed to update cache"):
320
- task = tileset.update_cache()
324
+ task = tileset.update_cache(from_zoom=0, to_zoom=2)
321
325
 
322
326
 
323
327
  def test_clear_cache(api, mock_tileset_data):
@@ -592,11 +592,16 @@ def test_create_view(api, mock_vector_data, layer_type, mock_view_data):
592
592
 
593
593
 
594
594
  @pytest.mark.parametrize("layer_type", [type for type in LayerType])
595
- def test_get_tile(api, mock_vector_data, layer_type):
595
+ def test_get_tile_pbf_url(api, mock_vector_data, layer_type):
596
596
  """Test getting a vector tile."""
597
597
  layer = VectorLayer(api, uuid=mock_vector_data['uuid'], data=mock_vector_data, layer_type=layer_type)
598
- endpoint = layer.get_tile(x=1, y=2, z=3)
599
- assert endpoint == f'{layer.BASE_ENDPOINT}{layer.endpoint}tiles/3/1/2.pbf'
598
+ url = layer.get_tile_pbf_url(x=1, y=2, z=3)
599
+ assert url == f'{layer.api.base_url}{layer.endpoint}tiles/3/1/2.pbf'
600
+ # apikey
601
+ api.access_token = ''
602
+ api.apikey = 'apikey_1234'
603
+ url = layer.get_tile_pbf_url(x=1, y=2, z=3)
604
+ assert url == f'{layer.api.base_url}{layer.endpoint}tiles/3/1/2.pbf?apikey=apikey_1234'
600
605
 
601
606
 
602
607
  @pytest.mark.parametrize("layer_type", [type for type in LayerType])
@@ -520,7 +520,7 @@ def test_export_features(api, mock_view_data, layer_type, mock_success_task_data
520
520
 
521
521
 
522
522
  @pytest.mark.parametrize("layer_type", [type for type in LayerType])
523
- def test_get_tile(api, mock_view_data, layer_type):
523
+ def test_get_tile_pbf_url(api, mock_view_data, layer_type):
524
524
  """Test getting a vector tile."""
525
525
  view = VectorLayerView(
526
526
  api=api,
@@ -528,8 +528,8 @@ def test_get_tile(api, mock_view_data, layer_type):
528
528
  layer_type=layer_type,
529
529
  data=mock_view_data
530
530
  )
531
- endpoint = view.get_tile(x=1, y=2, z=3)
532
- assert endpoint == f'{view.BASE_ENDPOINT}{view.endpoint}tiles/3/1/2.pbf'
531
+ endpoint = view.get_tile_pbf_url(x=1, y=2, z=3)
532
+ assert endpoint == f'{view.api.base_url}{view.endpoint}tiles/3/1/2.pbf'
533
533
 
534
534
 
535
535
  @pytest.mark.parametrize("layer_type", [type for type in LayerType])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes