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/__init__.py +1 -1
- morecantile/data/NZTM2000Quad.json +0 -1
- morecantile/data/WebMercatorQuad.json +362 -260
- morecantile/defaults.py +13 -13
- morecantile/models.py +231 -127
- morecantile/scripts/cli.py +19 -5
- morecantile/utils.py +27 -7
- {morecantile-6.1.0.dist-info → morecantile-7.0.0.dist-info}/METADATA +39 -35
- {morecantile-6.1.0.dist-info → morecantile-7.0.0.dist-info}/RECORD +12 -12
- {morecantile-6.1.0.dist-info → morecantile-7.0.0.dist-info}/WHEEL +1 -1
- morecantile-7.0.0.dist-info/entry_points.txt +2 -0
- morecantile-6.1.0.dist-info/entry_points.txt +0 -3
- {morecantile-6.1.0.dist-info → morecantile-7.0.0.dist-info/licenses}/LICENSE +0 -0
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
|
-
|
|
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.
|
|
33
|
+
if identifier not in self.tilematrixsets:
|
|
34
34
|
raise InvalidIdentifier(f"Invalid identifier: {identifier}")
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
tilematrix = self.tilematrixsets[identifier]
|
|
37
37
|
|
|
38
38
|
# We lazyload the TMS document only when called
|
|
39
|
-
if isinstance(
|
|
40
|
-
with
|
|
41
|
-
|
|
42
|
-
self.
|
|
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
|
|
44
|
+
return deepcopy(tilematrix)
|
|
45
45
|
|
|
46
46
|
def list(self) -> List[str]:
|
|
47
47
|
"""List registered TMS."""
|
|
48
|
-
return list(self.
|
|
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.
|
|
58
|
-
raise
|
|
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.
|
|
60
|
+
return TileMatrixSets({**self.tilematrixsets, **custom_tms})
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
tms = TileMatrixSets(copy(default_tms)) # noqa
|