treat empty geometries correctly

This commit is contained in:
Laura Klünder 2018-12-23 19:50:53 +01:00
parent bd2a512df3
commit 7754643c4b
2 changed files with 4 additions and 0 deletions

View file

@ -106,6 +106,8 @@ class GeometryField(models.TextField):
if value is None:
return None
self._validate_geomtype(value, exception=TypeError)
if value.is_empty:
raise Exception('Cannot save empty geometry.')
return json.dumps(self.get_final_value(value, as_json=True))
def value_to_string(self, obj):

View file

@ -41,6 +41,8 @@ class WrappedGeometry():
@cached_property
def wrapped_geom(self):
if not self.wrapped_geojson['coordinates']:
return GeometryCollection()
return shapely_shape(self.wrapped_geojson)
def __getattr__(self, name):