def test_make_feature(self): feature1 = Feature.build_from_geometry('POINT (1 2)', properties=dict(x=1, y=2)) self.assertEqual(feature1.crs.srid, 4326) self.assertEqual(feature1.properties['x'], 1) self.assertEqual(feature1.properties['y'], 2) feature2 = Feature.build_from_geojson(feature1.__geo_interface__) feature3 = Feature.build_from_geojson(feature1.geojson) self.assertTrue(feature2.equals(feature3))
def test_update_geometry(self): feature1 = Feature.build_from_geometry('POINT (1 2)', properties=dict(x=1, y=2)) metadata1 = feature1.metadata feature1.geometry = Geometry.build_geometry('POINT (3 4)') metadata2 = feature1.metadata self.assertNotEqual(metadata1, metadata2)
def test_create_from_geojson(self): for k, v in pydata.iteritems(): data = {'type': 'Feature', 'geometry': v, 'properties': {'type': 'snow'}, 'crs': {'type': 'name', 'properties': { 'name': 'EPSG:4326' }}} feature = Feature.build_from_geojson(json.dumps(data)) self.assertTrue(feature.geometry.equals(Geometry.build_geometry(v)))
def test_pickle(self): for k, v in pydata.iteritems(): data = {'type': 'Feature', 'geometry': v, 'properties': {'type': 'snow'}, 'crs': {'type': 'name', 'properties': { 'name': 'EPSG:4326' }}} feature = Feature.build_from_geojson(json.dumps(data)) buf = pickle.dumps(feature) feature2 = pickle.loads(buf) self.assertEqual(feature2.metadata, feature.metadata) self.assertTrue(feature2.equals(feature))
def test_duplicate(self): feature = Feature.build_from_geometry('POINT(1 1)', srid=4326) feature2 = feature.duplicate() self.assertTrue(feature2.equals(feature))