예제 #1
0
 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))
예제 #2
0
 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))
예제 #3
0
 def test_plot_comparison(self, example_shp, tmpdir):
     matplotlib.pyplot.clf()
     x, y, _ = spatial_efd.ProcessGeometry(example_shp[0])
     coeffs = spatial_efd.CalculateEFD(x, y, 10)
     ax = spatial_efd.InitPlot()
     spatial_efd.plotComparison(ax, coeffs, 10, x, y)
     spatial_efd.SavePlot(ax, 10, tmpdir, 'png')
     assert os.path.isfile('{0}_10.png'.format(tmpdir))
예제 #4
0
 def test_plot_comparison_norm(self, example_shp, tmpdir):
     x, y, _ = spatial_efd.ProcessGeometry(example_shp[1])
     coeffs = spatial_efd.CalculateEFD(x, y, 10)
     coeffs, rotation = spatial_efd.normalize_efd(coeffs,
                                                  size_invariant=False)
     ax = spatial_efd.InitPlot()
     spatial_efd.plotComparison(ax, coeffs, 7, x, y, rotation=rotation)
     spatial_efd.SavePlot(ax, 7, tmpdir, 'png')
     assert os.path.isfile('{0}_7.png'.format(tmpdir))
예제 #5
0
    def test_write_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)

        with warnings.catch_warnings(record=True) as w:
            spatial_efd.generateShapefile(tmpdir.strpath, 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
예제 #6
0
 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)
예제 #7
0
 def test_process_geometry(self, example_shp, expected):
     x, y, c = spatial_efd.ProcessGeometry(example_shp[1])
     ntest.assert_almost_equal(c, expected['process_geometry']['c'])
     ntest.assert_almost_equal(x[:10], expected['process_geometry']['x'])
     ntest.assert_almost_equal(y[:10], expected['process_geometry']['y'])