treat empty geometries correctly
This commit is contained in:
parent
bd2a512df3
commit
7754643c4b
2 changed files with 4 additions and 0 deletions
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue