def test_save_shapefile(self, example_shp, tmpdir): x, y, _ = spatial_efd.ProcessGeometry(example_shp[1]) coeffs = spatial_efd.CalculateEFD(x, y, 10) shape = spatial_efd.generateShapefile() shape = spatial_efd.writeGeometry(coeffs, x, y, 4, shape, 1) spatial_efd.saveShapefile(tmpdir.strpath, shape, prj=None) assert os.path.isfile('{}.shp'.format(tmpdir))
def test_write_geometry_prj(self, example_shp, tmpdir, shp_paths): x, y, _ = spatial_efd.ProcessGeometry(example_shp[1]) coeffs = spatial_efd.CalculateEFD(x, y, 10) shape = spatial_efd.generateShapefile(tmpdir.strpath, prj=shp_paths[1]) shape = spatial_efd.writeGeometry(coeffs, x, y, 4, shape, 1) assert os.path.isfile('{}.shp'.format(tmpdir)) assert os.path.isfile('{}.prj'.format(tmpdir))
def test_save_shapefile_prj_wrong(self, example_shp, tmpdir, shp_paths, warn_wrong_prj): x, y, _ = spatial_efd.ProcessGeometry(example_shp[1]) coeffs = spatial_efd.CalculateEFD(x, y, 10) shape = spatial_efd.generateShapefile() shape = spatial_efd.writeGeometry(coeffs, x, y, 4, shape, 1) with warnings.catch_warnings(record=True) as w: spatial_efd.saveShapefile(tmpdir.strpath, shape, prj=shp_paths[0]) assert os.path.isfile('{0}.shp'.format(tmpdir)) assert not os.path.isfile('{0}.prj'.format(tmpdir)) assert len(w) == 1 assert issubclass(w[0].category, UserWarning) assert clean_warning(w[0].message) == warn_wrong_prj
def test_write_geometry(self, example_shp): x, y, _ = spatial_efd.ProcessGeometry(example_shp[1]) coeffs = spatial_efd.CalculateEFD(x, y, 10) shape = spatial_efd.generateShapefile() shape = spatial_efd.writeGeometry(coeffs, x, y, 4, shape, 1) assert isinstance(shape, shp.Writer)