morecantile 5.3.0__py3-none-any.whl → 5.3.1__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 CHANGED
@@ -8,7 +8,7 @@ Refs:
8
8
 
9
9
  """
10
10
 
11
- __version__ = "5.3.0"
11
+ __version__ = "5.3.1"
12
12
 
13
13
  from .commons import BoundingBox, Coords, Tile # noqa
14
14
  from .defaults import TileMatrixSets, tms # noqa
morecantile/models.py CHANGED
@@ -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
- w = max(self.bbox.left, w)
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:
morecantile/utils.py CHANGED
@@ -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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: morecantile
3
- Version: 5.3.0
3
+ Version: 5.3.1
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"
@@ -1,10 +1,10 @@
1
- morecantile/__init__.py,sha256=XKZkt0ZtZzGh-5bWypyvUDNsesXKWGUs-azRRAn1NfE,436
1
+ morecantile/__init__.py,sha256=xp0X6IQ8GGTQkJFJ9m2nrxtfkWW4njt-9MjFRNVKgUA,436
2
2
  morecantile/commons.py,sha256=nOj5f5K5EbDZiC0QTK2f14Mpkz6YIZyCaaUI0S9aWIw,1015
3
3
  morecantile/defaults.py,sha256=9lvHmZ9WM_J5uNCS9VWEy8O5_x2dA2Spvk4H5aHv6UQ,1804
4
4
  morecantile/errors.py,sha256=rhtdpNglfEz5nC8I-BJKUr_gkOwAPwVi1vhLFJ2StYw,907
5
- morecantile/models.py,sha256=s7G4fBNO3yZowZROB8xwy3tGIeNzbhU1IJkHvkGIQek,51368
5
+ morecantile/models.py,sha256=mRCIDQ2VjMjNigF9mUiPy2oLehGmSSwD3VdVO_OH0Wc,51649
6
6
  morecantile/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- morecantile/utils.py,sha256=J37ixKq_lJC23bqJSAf01mfS-ZEHizvt2uqVE47dPRE,3364
7
+ morecantile/utils.py,sha256=-JUTcrwhT_TEWAPWV8YQBQJoYU2HfVkqQEJaggtnKJg,4020
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
@@ -21,8 +21,8 @@ morecantile/data/WorldCRS84Quad.json,sha256=l0Wf2faYwzRwO0mG-Tea1Vydpi7V1Oel5L9l
21
21
  morecantile/data/WorldMercatorWGS84Quad.json,sha256=JaqoBSu5qVJmL-J7oSVU1etP2OPWx_aVaTc68dGX0Ec,7001
22
22
  morecantile/scripts/__init__.py,sha256=-CJncfgWDnSZ8au-SJtgX-OFgCddlf7___d91qQcqQM,23
23
23
  morecantile/scripts/cli.py,sha256=zSE15udt2Mb8IR9XB01gm8k_L65ON4_WAkpcJmQazlI,16859
24
- morecantile-5.3.0.dist-info/entry_points.txt,sha256=keoXuYgnX-mdrGWwXIHqEkSZjQK_iAmtmdrtZ3sCT24,59
25
- morecantile-5.3.0.dist-info/LICENSE,sha256=18IxFIta7rF_RcVSIgLUUd_alyfQ9bGoZKQm5vOarGU,1073
26
- morecantile-5.3.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
27
- morecantile-5.3.0.dist-info/METADATA,sha256=Jf5wi_gB8q5aFXFaSceFYQZ46uFEn9tJFBbCBS6UZiE,6890
28
- morecantile-5.3.0.dist-info/RECORD,,
24
+ morecantile-5.3.1.dist-info/entry_points.txt,sha256=keoXuYgnX-mdrGWwXIHqEkSZjQK_iAmtmdrtZ3sCT24,59
25
+ morecantile-5.3.1.dist-info/LICENSE,sha256=18IxFIta7rF_RcVSIgLUUd_alyfQ9bGoZKQm5vOarGU,1073
26
+ morecantile-5.3.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
27
+ morecantile-5.3.1.dist-info/METADATA,sha256=1HUu9x4xTg7y2cmoqGghUW127eupnemilcY7gK2UYlE,6938
28
+ morecantile-5.3.1.dist-info/RECORD,,