# Issue #381
* adds another validity check to SimpleGeomForm (is_size_valid) to make sure the area of the entered geometry is somehow rational (>= 1m²) * optimizes performance of django command sanitize_db * extends Geometry model with two new attributes, holding timestamps when a parcel calculation has been started and ended * finally drops unused update_parcel_wfs in favor of update_parcels in Geometry model * refactors update_parcel method * adds geometry buffer fallback in schneider/fetcher.py to avoid emptying of geometries when parcels shall be fetched * finally removes utils/wfs/spatial.py * extends GeomParcelsView according to #381 * updates translations * removes redundant psycopg2-binary requirement
This commit is contained in:
@@ -98,12 +98,14 @@ class SimpleGeomForm(BaseForm):
|
||||
|
||||
if g.geom_type not in accepted_ogr_types:
|
||||
self.add_error("geom", _("Only surfaces allowed. Points or lines must be buffered."))
|
||||
is_valid = False
|
||||
is_valid &= False
|
||||
return is_valid
|
||||
|
||||
is_valid &= self.__is_size_valid(g)
|
||||
|
||||
polygon = Polygon.from_ewkt(g.ewkt)
|
||||
is_valid = polygon.valid
|
||||
if not is_valid:
|
||||
is_valid &= polygon.valid
|
||||
if not polygon.valid:
|
||||
self.add_error("geom", polygon.valid_reason)
|
||||
return is_valid
|
||||
|
||||
@@ -137,6 +139,24 @@ class SimpleGeomForm(BaseForm):
|
||||
|
||||
return num_vertices <= GEOM_MAX_VERTICES
|
||||
|
||||
def __is_size_valid(self, geom: gdal.OGRGeometry):
|
||||
""" Checks whether the number of vertices in the geometry is not too high
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
is_area_valid = geom.area > 1 # > 1m² (SRID:25832)
|
||||
|
||||
if not is_area_valid:
|
||||
self.add_error(
|
||||
"geom",
|
||||
_("Geometry must be greater than 1m². Currently is {}m²").format(
|
||||
float(geom.area)
|
||||
)
|
||||
)
|
||||
|
||||
return is_area_valid
|
||||
|
||||
def __simplify_geometry(self, geom, max_vert: int):
|
||||
""" Simplifies a geometry
|
||||
|
||||
|
||||
Reference in New Issue
Block a user