Browse Source

Actually, lets only accept Polygon and Multipolygon

GeometryCollection doesn't make any sense for now, since MultiPolygon is
already a collection of polygons
Gu1 11 years ago
parent
commit
eba43f063c
2 changed files with 7 additions and 14 deletions
  1. 1 1
      ispformat/specs/0.1/isp-schema-spec.rst
  2. 6 13
      ispformat/validator/schemavalidator.py

+ 1 - 1
ispformat/specs/0.1/isp-schema-spec.rst

@@ -49,7 +49,7 @@ The ISP format is meant to allow an ISP to share relevant data and informations,
 =====================
 The "area" key of a coveredArea object, is meant to represent a geographic area covered by the ISP. When present, it must contain a valid GeoJSON object, as defined in [geojson-spec]_.
 
-As an additional restriction, it MUST only contain GeoJSON geometries of type Polygon, MultiPolygon or GeometryCollection.
+As an additional restriction, it MUST only contain GeoJSON geometries of type Polygon or MultiPolygon.
 
 
 4. Implementing the format

+ 6 - 13
ispformat/validator/schemavalidator.py

@@ -14,22 +14,15 @@ class MyRefResolver(RefResolver):
         raise RefResolutionError("LOL NOPE")
 
 
-geojson_allowed_types=('Polygon', 'MultiPolygon', 'GeometryCollection')
-def validate_geojson(_d):
+geojson_allowed_types=('Polygon', 'MultiPolygon')
+def validate_geojson(d):
     """
     Make sure a geojson dict only contains allowed geometry types
     """
-    def inner(d):
-        type_=d.get('type')
-        if type_ not in geojson_allowed_types:
-            return False
-        if type_ == 'GeometryCollection':
-            for d2 in d['geometries']:
-                if not inner(d2):
-                    return False
-        return True
-
-    return inner(_d)
+    type_=d.get('type')
+    if type_ not in geojson_allowed_types:
+        return False
+    return True
 
 
 def validate_isp(jdict):