Merge pull request 'Master' (#560) from master into Docker
Reviewed-on: #560
This commit was merged in pull request #560.
This commit is contained in:
@@ -156,6 +156,9 @@ class AbstractModelAPISerializer:
|
|||||||
if isinstance(geojson, dict):
|
if isinstance(geojson, dict):
|
||||||
geojson = json.dumps(geojson)
|
geojson = json.dumps(geojson)
|
||||||
geometry = geos.fromstr(geojson)
|
geometry = geos.fromstr(geojson)
|
||||||
|
is_4326 = Geometry.is_valid_4326(geometry)
|
||||||
|
if not is_4326:
|
||||||
|
raise ValueError("Geometry not in EPSG:4326 (WGS84). Unknown spatial reference system.")
|
||||||
geometry = Geometry.cast_to_rlp_srid(geometry)
|
geometry = Geometry.cast_to_rlp_srid(geometry)
|
||||||
geometry = Geometry.cast_to_multipolygon(geometry)
|
geometry = Geometry.cast_to_multipolygon(geometry)
|
||||||
return geometry
|
return geometry
|
||||||
|
|||||||
@@ -462,6 +462,26 @@ class Geometry(BaseResource):
|
|||||||
conflict_geoms = Geometry.objects.filter(id__in=conflict_geoms_id)
|
conflict_geoms = Geometry.objects.filter(id__in=conflict_geoms_id)
|
||||||
return conflict_geoms
|
return conflict_geoms
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_valid_4326(geometry):
|
||||||
|
""" Checks whether a given geometry's coordinates are in a valid range to be of EPSG:4326
|
||||||
|
|
||||||
|
Args:
|
||||||
|
geometry: The geometry
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ret_val (bool): Whether the geometry is valid EPSG:4326
|
||||||
|
"""
|
||||||
|
if not geometry.centroid.coords:
|
||||||
|
# No coordinates at all found, therefore technically proper 4326
|
||||||
|
return True
|
||||||
|
|
||||||
|
try:
|
||||||
|
lat,lon = geometry.centroid.coords
|
||||||
|
return (-90.0 <= lat <= 90.0) and (-180.0 <= lon <= 180.0)
|
||||||
|
except IndexError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class GeometryConflict(UuidModel):
|
class GeometryConflict(UuidModel):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user