[Git][debian-gis-team/antimeridian][upstream] New upstream version 0.3.5
Antonio Valentino (@antonio.valentino)
gitlab at salsa.debian.org
Wed May 8 06:16:58 BST 2024
Antonio Valentino pushed to branch upstream at Debian GIS Project / antimeridian
Commits:
0d8532d9 by Antonio Valentino at 2024-05-08T04:56:33+00:00
New upstream version 0.3.5
- - - - -
7 changed files:
- .pre-commit-config.yaml
- CHANGELOG.md
- pyproject.toml
- src/antimeridian/_implementation.py
- + tests/data/input/issues-81.json
- + tests/data/output/issues-81.json
- tests/test_polygon.py
Changes:
=====================================
.pre-commit-config.yaml
=====================================
@@ -6,24 +6,17 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- - repo: https://github.com/psf/black
- rev: 24.3.0
- hooks:
- - id: black
- - repo: https://github.com/adamchainz/blacken-docs
- rev: "1.16.0"
- hooks:
- - id: blacken-docs
- additional_dependencies:
- - black~=23.3
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies:
- click~=8.1.6
- - pytest~=7.3
+ - pytest~=8.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: ruff
+ types_or: [python, pyi, jupyter]
+ - id: ruff-format
+ types_or: [python, pyi, jupyter]
=====================================
CHANGELOG.md
=====================================
@@ -6,7 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
-## [0.3.4]
+## [0.3.5] - 2024-05-05
+
+### Fixed
+
+- Correct the case when neighboring points are on 180 and -180 and are not part of a latitude band ([#114](https://github.com/gadomski/antimeridian/pull/114))
+
+## [0.3.4] - 2024-03-29
### Fixed
@@ -122,7 +128,9 @@ This v0.1.0 release is to indicate that we think that this package is ready to u
Initial release.
-[unreleased]: https://github.com/gadomski/antimeridian/compare/v0.3.3...HEAD
+[unreleased]: https://github.com/gadomski/antimeridian/compare/v0.3.5...HEAD
+[0.3.5]: https://github.com/gadomsk/antimeridian/compare/v0.3.4...v0.3.5
+[0.3.4]: https://github.com/gadomsk/antimeridian/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/gadomsk/antimeridian/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/gadomsk/antimeridian/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/gadomsk/antimeridian/compare/v0.3.0...v0.3.1
=====================================
pyproject.toml
=====================================
@@ -1,6 +1,6 @@
[project]
name = "antimeridian"
-version = "0.3.4"
+version = "0.3.5"
authors = [{ name = "Pete Gadomski", email = "pete.gadomski at gmail.com" }]
description = "Fix GeoJSON geometries that cross the antimeridian"
readme = "README.md"
@@ -21,14 +21,12 @@ Changelog = "https://github.com/gadomski/antimeridian/blob/main/CHANGELOG.md"
[project.optional-dependencies]
cli = ["click~=8.1.6"]
dev = [
- "black~=24.0",
- "blacken-docs~=1.13",
"mypy~=1.2",
"packaging~=24.0",
"pre-commit~=3.2",
"pytest~=8.0",
"pytest-console-scripts~=1.3",
- "ruff==0.3.4",
+ "ruff~=0.4.2",
"tomli~=2.0; python_version<'3.11'",
"typing_extensions; python_version<'3.10'",
]
@@ -62,7 +60,7 @@ ignore_missing_imports = true
filterwarnings = ["error"]
[tool.ruff]
-select = ["F", "E", "W", "I", "ERA", "RUF"]
+lint.select = ["F", "E", "W", "I", "ERA", "RUF"]
[build-system]
requires = ["setuptools >= 64"]
=====================================
src/antimeridian/_implementation.py
=====================================
@@ -381,8 +381,10 @@ def fix_polygon_to_list(
force_south_pole: bool,
fix_winding: bool,
) -> List[Polygon]:
- segments = segment(list(polygon.exterior.coords))
+ exterior = normalize(list(polygon.exterior.coords))
+ segments = segment(exterior)
if not segments:
+ polygon = Polygon(shell=exterior, holes=polygon.interiors)
if fix_winding and (
not shapely.is_ccw(polygon.exterior)
or any(shapely.is_ccw(interior) for interior in polygon.interiors)
@@ -425,18 +427,40 @@ def fix_polygon_to_list(
return polygons
-def segment(coords: List[XY]) -> List[List[XY]]:
- segment = []
- segments = []
+def normalize(coords: List[XY]) -> List[XY]:
+ original = list(coords)
+ all_are_on_antimeridian = True
for i, point in enumerate(coords):
# Ensure all longitudes are between -180 and 180, and that tiny floating
# point differences are ignored.
if numpy.isclose(point[0], 180):
- coords[i] = (180, point[1])
+ # https://github.com/gadomski/antimeridian/issues/81
+ if abs(coords[i][1]) != 90 and numpy.isclose(
+ coords[(i - 1) % len(coords)][0], -180
+ ):
+ coords[i] = (-180, point[1])
+ else:
+ coords[i] = (180, point[1])
elif numpy.isclose(point[0], -180):
- coords[i] = (-180, point[1])
+ # https://github.com/gadomski/antimeridian/issues/81
+ if abs(coords[i][1]) != 90 and numpy.isclose(
+ coords[(i - 1) % len(coords)][0], 180
+ ):
+ coords[i] = (180, point[1])
+ else:
+ coords[i] = (-180, point[1])
else:
coords[i] = (((point[0] + 180) % 360) - 180, point[1])
+ all_are_on_antimeridian = False
+ if all_are_on_antimeridian:
+ return original
+ else:
+ return coords
+
+
+def segment(coords: List[XY]) -> List[List[XY]]:
+ segment = []
+ segments = []
for start, end in zip(coords, coords[1:]):
segment.append(start)
if (end[0] - start[0] > 180) and (end[0] - start[0] != 360): # left
=====================================
tests/data/input/issues-81.json
=====================================
@@ -0,0 +1,27 @@
+{
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 166,
+ 77
+ ],
+ [
+ 180,
+ 78
+ ],
+ [
+ -180,
+ 81
+ ],
+ [
+ 162,
+ 81
+ ],
+ [
+ 166,
+ 77
+ ]
+ ]
+ ]
+}
=====================================
tests/data/output/issues-81.json
=====================================
@@ -0,0 +1,27 @@
+{
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 166,
+ 77
+ ],
+ [
+ 180,
+ 78
+ ],
+ [
+ 180,
+ 81
+ ],
+ [
+ 162,
+ 81
+ ],
+ [
+ 166,
+ 77
+ ]
+ ]
+ ]
+}
=====================================
tests/test_polygon.py
=====================================
@@ -17,6 +17,7 @@ from .conftest import Reader
"complex-split",
"crossing-latitude",
"extra-crossing",
+ "issues-81",
"latitude-band",
"north-pole",
"one-hole",
View it on GitLab: https://salsa.debian.org/debian-gis-team/antimeridian/-/commit/0d8532d91aea721587852bb0a0a78d1fb46cafe9
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/antimeridian/-/commit/0d8532d91aea721587852bb0a0a78d1fb46cafe9
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20240508/950bfc4e/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list