Ejemplo n.º 1
0
 def assertToShape(self, first_shp, esri_spec, esri_spec_copy):
     shp = to_shape(esri_spec)
     shp_copy = to_shape(esri_spec_copy)
     self.assertEqual(getattr(first_shp, '__geo_interface__'),
                      getattr(shp, '__geo_interface__'))
     self.assertEqual(getattr(first_shp, '__geo_interface__'),
                      getattr(shp_copy, '__geo_interface__'))
Ejemplo n.º 2
0
    def geometry(self, value):
        if value is None and (self._where is not None
                              or self._layerDefs is not None):
            return
        elif value is None and self._where is None and self._layerDefs is None:
            raise HTTPBadRequest(
                'Please provide the parameter geometry  (Required)')
        else:
            try:
                if self._geometryType == 'esriGeometryEnvelope':
                    self._geometry = esrijson.to_shape(
                        [float_raise_nan(c) for c in value.split(',')])
                elif self._geometryType == 'esriGeometryPoint' \
                        and 'x' not in value and 'y' not in value:
                    # Simple simplified point geometry
                    value = [float_raise_nan(c) for c in value.split(',')]
                    self._geometry = esrijson.to_shape({
                        'x': value[0],
                        'y': value[1]
                    })
                else:
                    self._geometry = esrijson.to_shape(esrijson.loads(value))

            except Exception:
                raise HTTPBadRequest('Please provide a valid geometry')
        if (self._geometryType == u'esriGeometryPolyline' and not isinstance(self._geometry, LineString)) \
                or (self._geometryType == u'esriGeometryPolygon' and not isinstance(self._geometry, Polygon)):
            raise HTTPBadRequest(
                u"Missmatch between 'geometryType': {} and provided 'geometry' parsed as '{}'"
                .format(self._geometryType, self._geometry.__class__.__name__))
Ejemplo n.º 3
0
 def geometry(self, value):
     if self._clipper:
         return
     if value is None:
         raise HTTPBadRequest('Please provide the parameter geometry (Required if clipper is not defined)')
     try:
         if self._geometryType == 'esriGeometryEnvelope':
             self._geometry = esrijson.to_shape([float_raise_nan(c) for c in value.split(',')])
         else:
             self._geometry = esrijson.to_shape(esrijson.loads(value))
     except:
         raise HTTPBadRequest('Please provide a valid geometry')
Ejemplo n.º 4
0
 def geometry(self, value):
     if self._clipper:
         return
     if value is None:
         raise HTTPBadRequest(
             'Please provide the parameter geometry (Required if clipper is not defined)'
         )
     try:
         if self._geometryType == 'esriGeometryEnvelope':
             self._geometry = esrijson.to_shape(
                 [float_raise_nan(c) for c in value.split(',')])
         else:
             self._geometry = esrijson.to_shape(esrijson.loads(value))
     except:
         raise HTTPBadRequest('Please provide a valid geometry')
Ejemplo n.º 5
0
 def geometry(self, value):
     if value is None and self._where is not None:
         return
     elif value is None and self._where is None:
         raise HTTPBadRequest('Please provide the parameter geometry  (Required)')
     else:
         try:
             if self._geometryType == 'esriGeometryEnvelope':
                 self._geometry = esrijson.to_shape([float_raise_nan(c) for c in value.split(',')])
             elif self._geometryType == 'esriGeometryPoint':
                 value = [float_raise_nan(c) for c in value.split(',')]
                 self._geometry = esrijson.to_shape({'x': value[0], 'y': value[1]})
             else:
                 self._geometry = esrijson.to_shape(esrijson.loads(value))
         except:
             raise HTTPBadRequest('Please provide a valid geometry')
Ejemplo n.º 6
0
 def mapExtent(self, value):
     if value is not None:
         try:
             self._mapExtent = esrijson.to_shape(
                 [float_raise_nan(c) for c in value.split(',')])
         except ValueError:
             raise HTTPBadRequest(
                 'Please provide numerical values for the parameter mapExtent'
             )
Ejemplo n.º 7
0
 def mapExtent(self, value):
     if value is None and self._where is not None:
         return
     elif value is None and self._where is None:
         raise HTTPBadRequest('Please provide the parameter mapExtent  (Required)')
     else:
         try:
             self._mapExtent = esrijson.to_shape([float_raise_nan(c) for c in value.split(',')])
         except:
             raise HTTPBadRequest('Please provide numerical values for the parameter mapExtent')
Ejemplo n.º 8
0
 def geometry(self, value):
     if value is None and self._where is not None:
         return
     elif value is None and self._where is None:
         raise HTTPBadRequest(
             'Please provide the parameter geometry  (Required)')
     else:
         try:
             if self._geometryType == 'esriGeometryEnvelope':
                 self._geometry = esrijson.to_shape(
                     [float_raise_nan(c) for c in value.split(',')])
             elif self._geometryType == 'esriGeometryPoint':
                 value = [float_raise_nan(c) for c in value.split(',')]
                 self._geometry = esrijson.to_shape({
                     'x': value[0],
                     'y': value[1]
                 })
             else:
                 self._geometry = esrijson.to_shape(esrijson.loads(value))
         except:
             raise HTTPBadRequest('Please provide a valid geometry')
Ejemplo n.º 9
0
 def mapExtent(self, value):
     if value is None and self._where is not None:
         return
     elif value is None and self._where is None:
         raise HTTPBadRequest(
             'Please provide the parameter mapExtent  (Required)')
     else:
         try:
             self._mapExtent = esrijson.to_shape(
                 [float_raise_nan(c) for c in value.split(',')])
         except:
             raise HTTPBadRequest(
                 'Please provide numerical values for the parameter mapExtent'
             )
Ejemplo n.º 10
0
 def mapExtent(self, value):
     if value is not None:
         try:
             self._mapExtent = esrijson.to_shape([float_raise_nan(c) for c in value.split(',')])
         except ValueError:
             raise HTTPBadRequest('Please provide numerical values for the parameter mapExtent')