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/scripts/cli.py
CHANGED
|
@@ -11,6 +11,8 @@ import morecantile
|
|
|
11
11
|
|
|
12
12
|
logger = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
|
+
WGS84_CRS = CRS.from_epsg(4326)
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
def configure_logging(verbosity):
|
|
16
18
|
"""Configure log verbosity.
|
|
@@ -189,6 +191,11 @@ def cli(ctx, verbose, quiet):
|
|
|
189
191
|
help="Path to TileMatrixSet JSON file.",
|
|
190
192
|
type=click.Path(),
|
|
191
193
|
)
|
|
194
|
+
@click.option(
|
|
195
|
+
"--crs",
|
|
196
|
+
help="Geographic CRS. Default to WGS84.",
|
|
197
|
+
type=str,
|
|
198
|
+
)
|
|
192
199
|
@click.pass_context
|
|
193
200
|
def shapes( # noqa: C901
|
|
194
201
|
ctx,
|
|
@@ -204,6 +211,7 @@ def shapes( # noqa: C901
|
|
|
204
211
|
extents,
|
|
205
212
|
buffer,
|
|
206
213
|
tms,
|
|
214
|
+
crs,
|
|
207
215
|
):
|
|
208
216
|
"""
|
|
209
217
|
Reads one or more Web Mercator tile descriptions
|
|
@@ -259,6 +267,7 @@ def shapes( # noqa: C901
|
|
|
259
267
|
projected=projected,
|
|
260
268
|
buffer=buffer,
|
|
261
269
|
precision=precision,
|
|
270
|
+
geographic_crs=CRS.from_user_input(crs) if crs else WGS84_CRS,
|
|
262
271
|
)
|
|
263
272
|
bbox = feature["bbox"]
|
|
264
273
|
w, s, e, n = bbox
|
|
@@ -402,7 +411,7 @@ def tiles(ctx, zoom, input, identifier, seq, tms): # noqa: C901
|
|
|
402
411
|
def tms(identifier):
|
|
403
412
|
"""Print TMS JSON."""
|
|
404
413
|
tms = morecantile.tms.get(identifier)
|
|
405
|
-
click.echo(tms.
|
|
414
|
+
click.echo(tms.model_dump_json(exclude_none=True))
|
|
406
415
|
|
|
407
416
|
|
|
408
417
|
################################################################################
|
|
@@ -445,8 +454,6 @@ def custom(
|
|
|
445
454
|
epsg, extent, name, minzoom, maxzoom, tile_width, tile_height, extent_epsg, title
|
|
446
455
|
):
|
|
447
456
|
"""Create Custom TMS."""
|
|
448
|
-
extent_crs = CRS.from_epsg(extent_epsg) if extent_epsg else None
|
|
449
|
-
|
|
450
457
|
tms = morecantile.TileMatrixSet.custom(
|
|
451
458
|
extent,
|
|
452
459
|
CRS.from_epsg(epsg),
|
|
@@ -455,10 +462,10 @@ def custom(
|
|
|
455
462
|
maxzoom=maxzoom,
|
|
456
463
|
tile_width=tile_width,
|
|
457
464
|
tile_height=tile_height,
|
|
458
|
-
extent_crs=
|
|
465
|
+
extent_crs=CRS.from_epsg(extent_epsg) if extent_epsg else None,
|
|
459
466
|
title=title or "Custom TileMatrixSet",
|
|
460
467
|
)
|
|
461
|
-
click.echo(tms.
|
|
468
|
+
click.echo(tms.model_dump_json(exclude_none=True))
|
|
462
469
|
|
|
463
470
|
|
|
464
471
|
################################################################################
|
|
@@ -526,6 +533,11 @@ def custom(
|
|
|
526
533
|
default=None,
|
|
527
534
|
help="Shift shape x and y values by a constant number",
|
|
528
535
|
)
|
|
536
|
+
@click.option(
|
|
537
|
+
"--crs",
|
|
538
|
+
help="Geographic CRS. Default to WGS84.",
|
|
539
|
+
type=str,
|
|
540
|
+
)
|
|
529
541
|
def tms_to_geojson( # noqa: C901
|
|
530
542
|
input,
|
|
531
543
|
level,
|
|
@@ -538,6 +550,7 @@ def tms_to_geojson( # noqa: C901
|
|
|
538
550
|
collect,
|
|
539
551
|
extents,
|
|
540
552
|
buffer,
|
|
553
|
+
crs,
|
|
541
554
|
):
|
|
542
555
|
"""Print TMS document as GeoJSON."""
|
|
543
556
|
tms = morecantile.TileMatrixSet(**json.load(input))
|
|
@@ -568,6 +581,7 @@ def tms_to_geojson( # noqa: C901
|
|
|
568
581
|
projected=projected,
|
|
569
582
|
buffer=buffer,
|
|
570
583
|
precision=precision,
|
|
584
|
+
geographic_crs=CRS.from_user_input(crs) if crs else WGS84_CRS,
|
|
571
585
|
)
|
|
572
586
|
bbox = feature["bbox"]
|
|
573
587
|
w, s, e, n = bbox
|
morecantile/utils.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""morecantile utils."""
|
|
2
2
|
|
|
3
3
|
import math
|
|
4
|
-
from typing import Dict, List
|
|
4
|
+
from typing import Dict, List, Tuple
|
|
5
5
|
|
|
6
6
|
from pyproj import CRS
|
|
7
7
|
from pyproj.enums import WktVersion
|
|
@@ -110,6 +110,28 @@ def point_in_bbox(point: Coords, bbox: BoundingBox, precision: int = 5) -> bool:
|
|
|
110
110
|
)
|
|
111
111
|
|
|
112
112
|
|
|
113
|
+
def truncate_coordinates(
|
|
114
|
+
lng: float, lat: float, bbox: BoundingBox
|
|
115
|
+
) -> Tuple[float, float]:
|
|
116
|
+
"""
|
|
117
|
+
Truncate coordinates to a given bbox.
|
|
118
|
+
|
|
119
|
+
Adapted from https://github.com/mapbox/mercantile/blob/master/mercantile/__init__.py
|
|
120
|
+
|
|
121
|
+
"""
|
|
122
|
+
if lng > bbox.right:
|
|
123
|
+
lng = bbox.right
|
|
124
|
+
elif lng < bbox.left:
|
|
125
|
+
lng = bbox.left
|
|
126
|
+
|
|
127
|
+
if lat > bbox.top:
|
|
128
|
+
lat = bbox.top
|
|
129
|
+
elif lat < bbox.bottom:
|
|
130
|
+
lat = bbox.bottom
|
|
131
|
+
|
|
132
|
+
return lng, lat
|
|
133
|
+
|
|
134
|
+
|
|
113
135
|
def is_power_of_two(number: int) -> bool:
|
|
114
136
|
"""Check if a number is a power of 2"""
|
|
115
137
|
return (number & (number - 1) == 0) and number != 0
|
|
@@ -118,12 +140,10 @@ def is_power_of_two(number: int) -> bool:
|
|
|
118
140
|
def check_quadkey_support(tms: List) -> bool:
|
|
119
141
|
"""Check if a Tile Matrix Set supports quadkeys"""
|
|
120
142
|
return all(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
for i, t in enumerate(tms[:-1])
|
|
126
|
-
]
|
|
143
|
+
(t.matrixWidth == t.matrixHeight)
|
|
144
|
+
and is_power_of_two(t.matrixWidth)
|
|
145
|
+
and ((t.matrixWidth * 2) == tms[i + 1].matrixWidth)
|
|
146
|
+
for i, t in enumerate(tms[:-1])
|
|
127
147
|
)
|
|
128
148
|
|
|
129
149
|
|
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: morecantile
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.0
|
|
4
4
|
Summary: Construct and use map tile grids (a.k.a TileMatrixSet / TMS).
|
|
5
|
-
|
|
5
|
+
Project-URL: Source, https://github.com/developmentseed/morecantile
|
|
6
|
+
Project-URL: Documentation, https://developmentseed.org/morecantile/
|
|
6
7
|
Author-email: Vincent Sarago <vincent@developmentseed.com>
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2020 Development Seed
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: GIS,Map Tile,TMS,TileMatrixSet
|
|
9
31
|
Classifier: Intended Audience :: Information Technology
|
|
10
32
|
Classifier: Intended Audience :: Science/Research
|
|
11
|
-
Classifier: License :: OSI Approved ::
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
34
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
35
|
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
38
|
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
39
|
+
Requires-Python: >=3.11
|
|
18
40
|
Requires-Dist: attrs
|
|
19
|
-
Requires-Dist:
|
|
41
|
+
Requires-Dist: click
|
|
20
42
|
Requires-Dist: pydantic~=2.0
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist: pytest-benchmark ; extra == "benchmark"
|
|
23
|
-
Requires-Dist: pre-commit ; extra == "dev"
|
|
24
|
-
Requires-Dist: bump-my-version ; extra == "dev"
|
|
25
|
-
Requires-Dist: mkdocs>=1.4.3 ; extra == "docs"
|
|
26
|
-
Requires-Dist: mkdocs-material[imaging]>=9.5 ; extra == "docs"
|
|
27
|
-
Requires-Dist: griffe-inherited-docstrings>=1.0.0 ; extra == "docs"
|
|
28
|
-
Requires-Dist: mkdocstrings[python]>=0.25.1 ; extra == "docs"
|
|
29
|
-
Requires-Dist: pygments ; extra == "docs"
|
|
30
|
-
Requires-Dist: rasterio>=1.2.1 ; extra == "rasterio"
|
|
31
|
-
Requires-Dist: mercantile ; extra == "test"
|
|
32
|
-
Requires-Dist: pytest ; extra == "test"
|
|
33
|
-
Requires-Dist: pytest-cov ; extra == "test"
|
|
34
|
-
Requires-Dist: rasterio>=1.2.1 ; extra == "test"
|
|
35
|
-
Project-URL: Documentation, https://developmentseed.org/morecantile/
|
|
36
|
-
Project-URL: Source, https://github.com/developmentseed/morecantile
|
|
37
|
-
Provides-Extra: benchmark
|
|
38
|
-
Provides-Extra: dev
|
|
39
|
-
Provides-Extra: docs
|
|
43
|
+
Requires-Dist: pyproj<4.0,>=3.1
|
|
40
44
|
Provides-Extra: rasterio
|
|
41
|
-
|
|
45
|
+
Requires-Dist: rasterio>=1.2.1; extra == 'rasterio'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
42
47
|
|
|
43
48
|
# Morecantile
|
|
44
49
|
|
|
@@ -86,12 +91,12 @@ Morecantile is like [mercantile](https://github.com/mapbox/mercantile) (the best
|
|
|
86
91
|
## Install
|
|
87
92
|
|
|
88
93
|
```bash
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
python -m pip install -U pip
|
|
95
|
+
python -m pip install morecantile
|
|
91
96
|
|
|
92
97
|
# Or install from source:
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
python -m pip install -U pip
|
|
99
|
+
python -m pip install git+https://github.com/developmentseed/morecantile.git
|
|
95
100
|
```
|
|
96
101
|
|
|
97
102
|
## Usage
|
|
@@ -177,4 +182,3 @@ See [LICENSE](https://github.com/developmentseed/morecantile/blob/main/LICENSE)
|
|
|
177
182
|
## Authors
|
|
178
183
|
|
|
179
184
|
Created by [Development Seed](<http://developmentseed.org>)
|
|
180
|
-
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
morecantile/__init__.py,sha256=
|
|
1
|
+
morecantile/__init__.py,sha256=7ZqZLq-TQmgh6C1xVQpzF66D83AO9RBtiq9iR_i1-og,436
|
|
2
2
|
morecantile/commons.py,sha256=iHElysLSMu-zb3h1G1-AJnQrZ6y-2GseZkoBkOuzcZ8,1031
|
|
3
|
-
morecantile/defaults.py,sha256=
|
|
3
|
+
morecantile/defaults.py,sha256=55ZkV0fw7nSAklZgQSL7IVvLspqe3RVpTZd_nNxPlTo,1951
|
|
4
4
|
morecantile/errors.py,sha256=rhtdpNglfEz5nC8I-BJKUr_gkOwAPwVi1vhLFJ2StYw,907
|
|
5
|
-
morecantile/models.py,sha256=
|
|
5
|
+
morecantile/models.py,sha256=dcQr3IWHc4iq5BwdgA4OqPyaKQKo5QX8XTE2AZ-I2no,56250
|
|
6
6
|
morecantile/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
morecantile/utils.py,sha256
|
|
7
|
+
morecantile/utils.py,sha256=6_J8i3u5RC9Z6ljzaWjvtU6woIMICsnIz-_B1enx7T8,4462
|
|
8
8
|
morecantile/data/CDB1GlobalGrid.json,sha256=VDc2ukAWtTQeCdOG8YMqsGO-D7eSzSCN1TEaBn2qLZI,36115
|
|
9
9
|
morecantile/data/CanadianNAD83_LCC.json,sha256=RuR9z5MjxKzU4KE-CutrzjpWBz9c-XXykKAxcD83veU,7267
|
|
10
10
|
morecantile/data/EuropeanETRS89_LAEAQuad.json,sha256=pR2Q7eAlLRG74SRdzYhXj19bf5qBvHrE6kzJ5cvko1Q,4679
|
|
11
11
|
morecantile/data/GNOSISGlobalGrid.json,sha256=xFrneT5mwP3gJkDeCTkyuSXniw9Afdoa1PqdbqmVRaA,74685
|
|
12
12
|
morecantile/data/LINZAntarticaMapTilegrid.json,sha256=dPfxQgpQlCAaaecmems9lTeFkPLbg0iBFqh5ItL-cpQ,5176
|
|
13
|
-
morecantile/data/NZTM2000Quad.json,sha256=
|
|
13
|
+
morecantile/data/NZTM2000Quad.json,sha256=3fXsFF1fQZExb5iZEpBxjaaUocfHUvRfckrTSPVmaSg,8388
|
|
14
14
|
morecantile/data/README.md,sha256=b0ipEXJ24gR_7UmAdZuRxb_UjvQxuzqrJQOYMED-JUo,257
|
|
15
15
|
morecantile/data/UPSAntarcticWGS84Quad.json,sha256=mmvm_HNKHpZloQPiN53LsIm8Ix9qZIV9CSxnkTRa--Y,7374
|
|
16
16
|
morecantile/data/UPSArcticWGS84Quad.json,sha256=BupbyUtl1gZOrah5wnVUfOa1cKV_6RShjGx5Q56ReBI,7365
|
|
17
17
|
morecantile/data/UTM31WGS84Quad.json,sha256=-cDrMJ-LFEFug7pVL85PKCdzTIWfiJwevv_QE5811Bs,7367
|
|
18
18
|
morecantile/data/WGS1984Quad.json,sha256=7qnkuMBPAjdahGREta6_uScNkDoK7pUbplA3froQnrs,6930
|
|
19
|
-
morecantile/data/WebMercatorQuad.json,sha256=
|
|
19
|
+
morecantile/data/WebMercatorQuad.json,sha256=SAJ1gBA0LccnIq3qIEoUxoJ6_45sLClKYa-zPad24gQ,11027
|
|
20
20
|
morecantile/data/WorldCRS84Quad.json,sha256=l0Wf2faYwzRwO0mG-Tea1Vydpi7V1Oel5L9l2NXHogk,7072
|
|
21
21
|
morecantile/data/WorldMercatorWGS84Quad.json,sha256=JaqoBSu5qVJmL-J7oSVU1etP2OPWx_aVaTc68dGX0Ec,7001
|
|
22
22
|
morecantile/scripts/__init__.py,sha256=-CJncfgWDnSZ8au-SJtgX-OFgCddlf7___d91qQcqQM,23
|
|
23
|
-
morecantile/scripts/cli.py,sha256=
|
|
24
|
-
morecantile-
|
|
25
|
-
morecantile-
|
|
26
|
-
morecantile-
|
|
27
|
-
morecantile-
|
|
28
|
-
morecantile-
|
|
23
|
+
morecantile/scripts/cli.py,sha256=X5Kq4H-fsNeO2IXocVw0fcc9oHHUxLeAVDXRUefkMAY,17742
|
|
24
|
+
morecantile-7.0.0.dist-info/METADATA,sha256=frw0l-CRklTHxKG8SSZUMdocqw1o2D2NClAdq5W54Hs,7760
|
|
25
|
+
morecantile-7.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
26
|
+
morecantile-7.0.0.dist-info/entry_points.txt,sha256=vbc6D3vR1kftKoSquOo7T1wtbIvRI-KkRsXsU1M0R2U,60
|
|
27
|
+
morecantile-7.0.0.dist-info/licenses/LICENSE,sha256=18IxFIta7rF_RcVSIgLUUd_alyfQ9bGoZKQm5vOarGU,1073
|
|
28
|
+
morecantile-7.0.0.dist-info/RECORD,,
|
|
File without changes
|