Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8de467ec24 | |||
| 238a9c4db8 | |||
| 7fe5340995 | |||
| 606f1ed311 |
@@ -180,6 +180,24 @@ class GeometryProcessor:
|
|||||||
is_area_valid = geom.area > 1 # > 1m² (SRID:25832)
|
is_area_valid = geom.area > 1 # > 1m² (SRID:25832)
|
||||||
return is_area_valid
|
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:
|
class GeoJsonValidator:
|
||||||
""" GeoJson Validator validates geojson (e.g. from API or form input)
|
""" GeoJson Validator validates geojson (e.g. from API or form input)
|
||||||
@@ -257,10 +275,10 @@ class GeoJsonValidator:
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
features = self._input_geojson.get("features", None)
|
features = self._input_geojson.get("features", [])
|
||||||
|
|
||||||
is_input_geojson_empty = len(self._input_geojson) == 0
|
is_input_geojson_empty = len(self._input_geojson) == 0
|
||||||
no_features_in_input_found = features is None
|
no_features_in_input_found = len(features) == 0
|
||||||
|
|
||||||
if not is_input_geojson_empty and no_features_in_input_found:
|
if not is_input_geojson_empty and no_features_in_input_found:
|
||||||
# check if _input_geojson is a feature itself
|
# check if _input_geojson is a feature itself
|
||||||
@@ -273,7 +291,6 @@ class GeoJsonValidator:
|
|||||||
else:
|
else:
|
||||||
self.__add_error("Input does not seem to be geojson")
|
self.__add_error("Input does not seem to be geojson")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validated_features = self.__validate_single_features(features)
|
validated_features = self.__validate_single_features(features)
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
@@ -306,6 +323,10 @@ class GeoJsonValidator:
|
|||||||
g = gdal.OGRGeometry(feature_geom, srs=self._srs)
|
g = gdal.OGRGeometry(feature_geom, srs=self._srs)
|
||||||
if g.empty:
|
if g.empty:
|
||||||
continue
|
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)
|
g = GeometryProcessor.cast_to_rlp_srid(g)
|
||||||
if not GeometryProcessor.is_valid_25832(g):
|
if not GeometryProcessor.is_valid_25832(g):
|
||||||
raise AssertionError(_("This feature does not hold valid EPSG:25832 coordinates:\n {}".format(g.geojson)))
|
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 ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@@ -2012,7 +2012,11 @@ msgstr "In Zwischenablage kopiert"
|
|||||||
msgid "Search"
|
msgid "Search"
|
||||||
msgstr "Suchen"
|
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 ""
|
msgid ""
|
||||||
"This feature does not hold valid EPSG:25832 coordinates:\n"
|
"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"
|
"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."
|
msgid "Only surfaces allowed. Points or lines must be buffered."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Nur Flächen erlaubt. Punkte oder Linien müssen zu Flächen gepuffert werden."
|
"Nur Flächen erlaubt. Punkte oder Linien müssen zu Flächen gepuffert werden."
|
||||||
|
|||||||
Reference in New Issue
Block a user