morecantile 6.1.0__py3-none-any.whl → 7.0.0__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.
morecantile/defaults.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import os
4
4
  import pathlib
5
- from copy import copy
5
+ from copy import copy, deepcopy
6
6
  from typing import Dict, List, Union
7
7
 
8
8
  import attr
@@ -26,26 +26,26 @@ default_tms: Dict[str, Union[TileMatrixSet, pathlib.Path]] = {
26
26
  class TileMatrixSets:
27
27
  """Default TileMatrixSets holder."""
28
28
 
29
- tms: Dict = attr.ib()
29
+ tilematrixsets: Dict = attr.ib()
30
30
 
31
31
  def get(self, identifier: str) -> TileMatrixSet:
32
32
  """Fetch a TMS."""
33
- if identifier not in self.tms:
33
+ if identifier not in self.tilematrixsets:
34
34
  raise InvalidIdentifier(f"Invalid identifier: {identifier}")
35
35
 
36
- tms = self.tms[identifier]
36
+ tilematrix = self.tilematrixsets[identifier]
37
37
 
38
38
  # We lazyload the TMS document only when called
39
- if isinstance(tms, pathlib.Path):
40
- with tms.open() as f:
41
- tms = TileMatrixSet.model_validate_json(f.read())
42
- self.tms[identifier] = tms
39
+ if isinstance(tilematrix, pathlib.Path):
40
+ with tilematrix.open() as f:
41
+ tilematrix = TileMatrixSet.model_validate_json(f.read())
42
+ self.tilematrixsets[identifier] = tilematrix
43
43
 
44
- return tms
44
+ return deepcopy(tilematrix)
45
45
 
46
46
  def list(self) -> List[str]:
47
47
  """List registered TMS."""
48
- return list(self.tms.keys())
48
+ return list(self.tilematrixsets.keys())
49
49
 
50
50
  def register(
51
51
  self,
@@ -54,10 +54,10 @@ class TileMatrixSets:
54
54
  ) -> "TileMatrixSets":
55
55
  """Register TileMatrixSet(s)."""
56
56
  for identifier in custom_tms.keys():
57
- if identifier in self.tms and not overwrite:
58
- raise Exception(f"{identifier} is already a registered TMS.")
57
+ if identifier in self.tilematrixsets and not overwrite:
58
+ raise InvalidIdentifier(f"{identifier} is already a registered TMS.")
59
59
 
60
- return TileMatrixSets({**self.tms, **custom_tms})
60
+ return TileMatrixSets({**self.tilematrixsets, **custom_tms})
61
61
 
62
62
 
63
63
  tms = TileMatrixSets(copy(default_tms)) # noqa