Skip to content

Commit

Permalink
Merge branch 'develop' into refactor-geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Oct 8, 2023
2 parents 69f8c17 + c84d504 commit 1ab5a2b
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 14 deletions.
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-docstring-first
Expand All @@ -21,41 +21,41 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/ikamensh/flynt/
rev: "0.78"
rev: "1.0.1"
hooks:
- id: flynt
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
- repo: https://github.com/hakancelikdev/unimport
rev: 0.15.0
rev: 1.0.0
hooks:
- id: unimport
args: [--remove, --include-star-import, --ignore-init, --gitignore]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py3-plus", "--py37-plus"]
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.259'
rev: 'v0.0.292'
hooks:
- id: ruff
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
17 changes: 11 additions & 6 deletions fastkml/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def _get_linear_ring(self, element: Element) -> Optional[geo.LinearRing]:
if lr is not None:
coords = self._get_coordinates(lr)
return geo.LinearRing(coords)
return None
return None # type: ignore[unreachable]

@no_type_check
def _get_geometry(self, element: Element) -> Optional[GeometryType]:
Expand Down Expand Up @@ -413,6 +413,11 @@ def _get_multigeometry(self, element: Element) -> Optional[MultiGeometryType]:
# MultiGeometry
geoms: List[Union[AnyGeometryType, None]] = []
if element.tag == f"{self.ns}MultiGeometry":
multigeometries = element.findall(f"{self.ns}MultiGeometry")
for multigeometry in multigeometries:
geom = Geometry(ns=self.ns)
geom.from_element(multigeometry)
geoms.append(geom.geometry)
points = element.findall(f"{self.ns}Point")
for point in points:
self._get_geometry_spec(point)
Expand Down Expand Up @@ -445,23 +450,23 @@ def _get_multigeometry(self, element: Element) -> Optional[MultiGeometryType]:
geom_types = {geom.geom_type for geom in clean_geoms}
if len(geom_types) > 1:
return geo.GeometryCollection(
clean_geoms,
clean_geoms, # type: ignore[arg-type]
)
if "Point" in geom_types:
return geo.MultiPoint.from_points(
*clean_geoms,
*clean_geoms, # type: ignore[arg-type]
)
elif "LineString" in geom_types:
return geo.MultiLineString.from_linestrings(
*clean_geoms,
*clean_geoms, # type: ignore[arg-type]
)
elif "Polygon" in geom_types:
return geo.MultiPolygon.from_polygons(
*clean_geoms,
*clean_geoms, # type: ignore[arg-type]
)
elif "LinearRing" in geom_types:
return geo.GeometryCollection(
clean_geoms,
clean_geoms, # type: ignore[arg-type]
)
return None

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ module = [
"fastkml.tests.oldunit_test", "fastkml.tests.config_test"
]
ignore_errors = true

[tool.ruff]
[tool.ruff.extend-per-file-ignores]
"tests/oldunit_test.py" = ["E501"]
Loading

0 comments on commit 1ab5a2b

Please sign in to comment.