Merge pull request 'Master' (#591) from master into Docker
Reviewed-on: #591
This commit was merged in pull request #591.
This commit is contained in:
@@ -180,6 +180,24 @@ class GeometryProcessor:
|
||||
is_area_valid = geom.area > 1 # > 1m² (SRID:25832)
|
||||
return is_area_valid
|
||||
|
||||
@staticmethod
|
||||
def is_valid_geometry(geom: gdal.OGRGeometry) -> bool:
|
||||
""" Checks whether the geometry is technically valid
|
||||
|
||||
Args:
|
||||
geom (OGRGeometry): The geom
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
try:
|
||||
# Check geometry validity by triggering some low cost processing like centroid calculation
|
||||
geom.centroid
|
||||
geom.boundary
|
||||
return True
|
||||
except gdal.GDALException as e:
|
||||
return False
|
||||
|
||||
|
||||
class GeoJsonValidator:
|
||||
""" GeoJson Validator validates geojson (e.g. from API or form input)
|
||||
@@ -305,6 +323,10 @@ class GeoJsonValidator:
|
||||
g = gdal.OGRGeometry(feature_geom, srs=self._srs)
|
||||
if g.empty:
|
||||
continue
|
||||
|
||||
if not GeometryProcessor.is_valid_geometry(g):
|
||||
raise AssertionError(_("This feature holds malicious parts and can not be processed!"))
|
||||
|
||||
g = GeometryProcessor.cast_to_rlp_srid(g)
|
||||
if not GeometryProcessor.is_valid_25832(g):
|
||||
raise AssertionError(_("This feature does not hold valid EPSG:25832 coordinates:\n {}".format(g.geojson)))
|
||||
|
||||
Binary file not shown.
@@ -45,7 +45,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-09-13 12:06+0200\n"
|
||||
"POT-Creation-Date: 2026-09-17 16:25+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -2012,7 +2012,11 @@ msgstr "In Zwischenablage kopiert"
|
||||
msgid "Search"
|
||||
msgstr "Suchen"
|
||||
|
||||
#: konova/utils/geometry/geometry_validator.py:311
|
||||
#: konova/utils/geometry/geometry_validator.py:328
|
||||
msgid "This feature holds malicious parts and can not be processed!"
|
||||
msgstr "Teile der Geometrie sind ungültig und können nicht verarbeitet werden!"
|
||||
|
||||
#: konova/utils/geometry/geometry_validator.py:332
|
||||
msgid ""
|
||||
"This feature does not hold valid EPSG:25832 coordinates:\n"
|
||||
" {}"
|
||||
@@ -2020,7 +2024,7 @@ msgstr ""
|
||||
"Dieses Feature enthält keine validen EPSG:25832 Koordinaten:\n"
|
||||
" {}"
|
||||
|
||||
#: konova/utils/geometry/geometry_validator.py:319
|
||||
#: konova/utils/geometry/geometry_validator.py:340
|
||||
msgid "Only surfaces allowed. Points or lines must be buffered."
|
||||
msgstr ""
|
||||
"Nur Flächen erlaubt. Punkte oder Linien müssen zu Flächen gepuffert werden."
|
||||
|
||||
Reference in New Issue
Block a user