fix geometry that has been invalidated by rounding before saving it
This commit is contained in:
parent
1f977ca9e6
commit
d494a59d6d
1 changed files with 5 additions and 1 deletions
|
@ -76,7 +76,11 @@ class GeometryField(models.TextField):
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
self._validate_geomtype(value, exception=TypeError)
|
self._validate_geomtype(value, exception=TypeError)
|
||||||
return json.dumps(format_geojson(mapping(value)))
|
json_value = format_geojson(mapping(value))
|
||||||
|
rounded_value = shape(json_value)
|
||||||
|
if not rounded_value.is_valid:
|
||||||
|
json_value = format_geojson(mapping(rounded_value.buffer(0)))
|
||||||
|
return json.dumps(json_value)
|
||||||
|
|
||||||
|
|
||||||
class JSONField(models.TextField):
|
class JSONField(models.TextField):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue