def test_geo_interface(self):
     shape = shapely.geometry.Point(-5, 10).buffer(5)
     obj = mock.Mock()
     obj.__geo_interface__ = shape.__geo_interface__
     as_shapely = _helpers.geometry_like_to_shapely(obj)
     self.assertIsInstance(as_shapely, shapely.geometry.Polygon)
     self.assertEqual(shape, as_shapely)
Ejemplo n.º 2
0
 def test_featurecollection(self):
     shapes = (shapely.geometry.Point(-5, 10), shapely.geometry.Point(-5, 10).buffer(5))
     fc = {
         'type': 'FeatureCollection',
         'features': [
             {
                 'type': 'Feature',
                 'geometry': shape.__geo_interface__,
                 'properties': {'foo': 'bar'}
             } for shape in shapes
         ],
     }
     as_shapely = _helpers.geometry_like_to_shapely(fc)
     self.assertIsInstance(as_shapely, shapely.geometry.GeometryCollection)
     self.assertEqual(as_shapely, shapely.geometry.GeometryCollection(shapes))
 def test_not_mapping_or_geo_interface(self):
     unhelpful = (1, 2, 3, 4)
     with self.assertRaises(TypeError):
         _helpers.geometry_like_to_shapely(unhelpful)
 def test_dict(self):
     shape = shapely.geometry.box(10, 20, 15, 30)
     mapping = shape.__geo_interface__
     as_shapely = _helpers.geometry_like_to_shapely(mapping)
     self.assertIsInstance(as_shapely, shapely.geometry.Polygon)
     self.assertEqual(shape, as_shapely)
 def test_shapely_obj(self):
     shape = shapely.geometry.box(10, 20, 15, 30)
     as_shapely = _helpers.geometry_like_to_shapely(shape)
     self.assertIsInstance(as_shapely, shapely.geometry.Polygon)
     self.assertEqual(shape, as_shapely)