morecantile 5.3.0__tar.gz → 5.4.0__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.
- {morecantile-5.3.0 → morecantile-5.4.0}/PKG-INFO +2 -1
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/__init__.py +1 -1
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/models.py +5 -2
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/scripts/cli.py +25 -6
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/utils.py +24 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/pyproject.toml +16 -0
- morecantile-5.3.0/.bumpversion.cfg +0 -9
- {morecantile-5.3.0 → morecantile-5.4.0}/.gitignore +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/.pre-commit-config.yaml +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/LICENSE +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/README.md +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/commons.py +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/CDB1GlobalGrid.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/CanadianNAD83_LCC.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/EuropeanETRS89_LAEAQuad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/GNOSISGlobalGrid.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/LINZAntarticaMapTilegrid.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/NZTM2000Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/README.md +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/UPSAntarcticWGS84Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/UPSArcticWGS84Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/UTM31WGS84Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/WGS1984Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/WebMercatorQuad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/WorldCRS84Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/data/WorldMercatorWGS84Quad.json +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/defaults.py +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/errors.py +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/py.typed +0 -0
- {morecantile-5.3.0 → morecantile-5.4.0}/morecantile/scripts/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: morecantile
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.4.0
|
|
4
4
|
Summary: Construct and use map tile grids (a.k.a TileMatrixSet / TMS).
|
|
5
5
|
Keywords: GIS,TMS,TileMatrixSet,Map Tile
|
|
6
6
|
Author-email: Vincent Sarago <vincent@developmentseed.com>
|
|
@@ -18,6 +18,7 @@ Requires-Dist: attrs
|
|
|
18
18
|
Requires-Dist: pyproj~=3.1
|
|
19
19
|
Requires-Dist: pydantic~=2.0
|
|
20
20
|
Requires-Dist: pre-commit ; extra == "dev"
|
|
21
|
+
Requires-Dist: bump-my-version ; extra == "dev"
|
|
21
22
|
Requires-Dist: mkdocs ; extra == "docs"
|
|
22
23
|
Requires-Dist: mkdocs-material ; extra == "docs"
|
|
23
24
|
Requires-Dist: pygments ; extra == "docs"
|
|
@@ -31,6 +31,7 @@ from morecantile.utils import (
|
|
|
31
31
|
_parse_tile_arg,
|
|
32
32
|
bbox_to_feature,
|
|
33
33
|
check_quadkey_support,
|
|
34
|
+
lons_contain_antimeridian,
|
|
34
35
|
meters_per_unit,
|
|
35
36
|
point_in_bbox,
|
|
36
37
|
to_rasterio_crs,
|
|
@@ -1252,9 +1253,11 @@ class TileMatrixSet(BaseModel, arbitrary_types_allowed=True):
|
|
|
1252
1253
|
|
|
1253
1254
|
for w, s, e, n in bboxes:
|
|
1254
1255
|
# Clamp bounding values.
|
|
1255
|
-
|
|
1256
|
+
ws_contain_180th = lons_contain_antimeridian(w, self.bbox.left)
|
|
1257
|
+
es_contain_180th = lons_contain_antimeridian(e, self.bbox.right)
|
|
1258
|
+
w = min(self.bbox.left, w) if ws_contain_180th else max(self.bbox.left, w)
|
|
1256
1259
|
s = max(self.bbox.bottom, s)
|
|
1257
|
-
e = min(self.bbox.right, e)
|
|
1260
|
+
e = max(self.bbox.right, e) if es_contain_180th else min(self.bbox.right, e)
|
|
1258
1261
|
n = min(self.bbox.top, n)
|
|
1259
1262
|
|
|
1260
1263
|
for z in zooms:
|
|
@@ -184,6 +184,11 @@ def cli(ctx, verbose, quiet):
|
|
|
184
184
|
default=None,
|
|
185
185
|
help="Shift shape x and y values by a constant number",
|
|
186
186
|
)
|
|
187
|
+
@click.option(
|
|
188
|
+
"--tms",
|
|
189
|
+
help="Path to TileMatrixSet JSON file.",
|
|
190
|
+
type=click.Path(),
|
|
191
|
+
)
|
|
187
192
|
@click.pass_context
|
|
188
193
|
def shapes( # noqa: C901
|
|
189
194
|
ctx,
|
|
@@ -198,6 +203,7 @@ def shapes( # noqa: C901
|
|
|
198
203
|
collect,
|
|
199
204
|
extents,
|
|
200
205
|
buffer,
|
|
206
|
+
tms,
|
|
201
207
|
):
|
|
202
208
|
"""
|
|
203
209
|
Reads one or more Web Mercator tile descriptions
|
|
@@ -217,7 +223,10 @@ def shapes( # noqa: C901
|
|
|
217
223
|
the properties object of the output feature.
|
|
218
224
|
|
|
219
225
|
"""
|
|
220
|
-
|
|
226
|
+
tilematrixset = morecantile.tms.get(identifier)
|
|
227
|
+
if tms:
|
|
228
|
+
with open(tms, "r") as f:
|
|
229
|
+
tilematrixset = morecantile.TileMatrixSet(**json.load(f))
|
|
221
230
|
|
|
222
231
|
dump_kwds = {"sort_keys": True}
|
|
223
232
|
if indent:
|
|
@@ -243,7 +252,7 @@ def shapes( # noqa: C901
|
|
|
243
252
|
else:
|
|
244
253
|
raise click.BadParameter("{0}".format(obj), param=input, param_hint="input")
|
|
245
254
|
|
|
246
|
-
feature =
|
|
255
|
+
feature = tilematrixset.feature(
|
|
247
256
|
(x, y, z),
|
|
248
257
|
fid=fid,
|
|
249
258
|
props=props,
|
|
@@ -273,7 +282,7 @@ def shapes( # noqa: C901
|
|
|
273
282
|
click.echo(
|
|
274
283
|
json.dumps(
|
|
275
284
|
{"type": "FeatureCollection", "bbox": bbox, "features": features},
|
|
276
|
-
**dump_kwds
|
|
285
|
+
**dump_kwds,
|
|
277
286
|
)
|
|
278
287
|
)
|
|
279
288
|
|
|
@@ -302,8 +311,13 @@ def shapes( # noqa: C901
|
|
|
302
311
|
default=False,
|
|
303
312
|
help="Write a RS-delimited JSON sequence (default is LF).",
|
|
304
313
|
)
|
|
314
|
+
@click.option(
|
|
315
|
+
"--tms",
|
|
316
|
+
help="Path to TileMatrixSet JSON file.",
|
|
317
|
+
type=click.Path(),
|
|
318
|
+
)
|
|
305
319
|
@click.pass_context
|
|
306
|
-
def tiles(ctx, zoom, input, identifier, seq): # noqa: C901
|
|
320
|
+
def tiles(ctx, zoom, input, identifier, seq, tms): # noqa: C901
|
|
307
321
|
"""
|
|
308
322
|
Lists TMS tiles at ZOOM level intersecting
|
|
309
323
|
GeoJSON [west, south, east, north] bounding boxen, features, or
|
|
@@ -324,7 +338,10 @@ def tiles(ctx, zoom, input, identifier, seq): # noqa: C901
|
|
|
324
338
|
[853, 1551, 12]
|
|
325
339
|
|
|
326
340
|
"""
|
|
327
|
-
|
|
341
|
+
tilematrixset = morecantile.tms.get(identifier)
|
|
342
|
+
if tms:
|
|
343
|
+
with open(tms, "r") as f:
|
|
344
|
+
tilematrixset = morecantile.TileMatrixSet(**json.load(f))
|
|
328
345
|
|
|
329
346
|
for obj in normalize_source(input):
|
|
330
347
|
if isinstance(obj, list):
|
|
@@ -362,7 +379,9 @@ def tiles(ctx, zoom, input, identifier, seq): # noqa: C901
|
|
|
362
379
|
east -= epsilon
|
|
363
380
|
north -= epsilon
|
|
364
381
|
|
|
365
|
-
for tile in
|
|
382
|
+
for tile in tilematrixset.tiles(
|
|
383
|
+
west, south, east, north, [zoom], truncate=False
|
|
384
|
+
):
|
|
366
385
|
vals = (tile.x, tile.y, zoom)
|
|
367
386
|
output = json.dumps(vals)
|
|
368
387
|
if seq:
|
|
@@ -40,6 +40,30 @@ def _parse_tile_arg(*args) -> Tile:
|
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
def lons_contain_antimeridian(lon1: float, lon2: float) -> bool:
|
|
44
|
+
"""
|
|
45
|
+
Check if the antimeridian (180th meridian) is between two longitude points
|
|
46
|
+
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
lon1: float
|
|
50
|
+
The first longitude.
|
|
51
|
+
lon2: float
|
|
52
|
+
The second longitude
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
A bool representing whether two longs contain the 180th meridian.
|
|
57
|
+
"""
|
|
58
|
+
lon1_clipped = max(-180.0, min(lon1, 180))
|
|
59
|
+
lon2_clipped = max(-180.0, min(lon2, 180))
|
|
60
|
+
lon1_converted = (lon1_clipped + 360) % 360
|
|
61
|
+
lon2_converted = (lon2_clipped + 360) % 360
|
|
62
|
+
ws = [lon1_converted, lon2_converted]
|
|
63
|
+
sorted(ws)
|
|
64
|
+
return ws[0] < 180 < ws[1]
|
|
65
|
+
|
|
66
|
+
|
|
43
67
|
def meters_per_unit(crs: CRS) -> float:
|
|
44
68
|
"""
|
|
45
69
|
Coefficient to convert the coordinate reference system (CRS)
|
|
@@ -37,6 +37,7 @@ test = [
|
|
|
37
37
|
]
|
|
38
38
|
dev = [
|
|
39
39
|
"pre-commit",
|
|
40
|
+
"bump-my-version",
|
|
40
41
|
]
|
|
41
42
|
docs = [
|
|
42
43
|
"mkdocs",
|
|
@@ -110,3 +111,18 @@ ignore = [
|
|
|
110
111
|
filterwarnings = [
|
|
111
112
|
"ignore:You will likely lose important projection*:UserWarning",
|
|
112
113
|
]
|
|
114
|
+
|
|
115
|
+
[tool.bumpversion]
|
|
116
|
+
current_version = "5.4.0"
|
|
117
|
+
|
|
118
|
+
search = "{current_version}"
|
|
119
|
+
replace = "{new_version}"
|
|
120
|
+
regex = false
|
|
121
|
+
tag = true
|
|
122
|
+
commit = true
|
|
123
|
+
tag_name = "{new_version}"
|
|
124
|
+
|
|
125
|
+
[[tool.bumpversion.files]]
|
|
126
|
+
filename = "morecantile/__init__.py"
|
|
127
|
+
search = '__version__ = "{current_version}"'
|
|
128
|
+
replace = '__version__ = "{new_version}"'
|
|
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
|