Example #1
0
    def test_streamable(self):
        """Can we distinguish streamable from non-streamable stages and pipeline"""
        rs = pdal.Reader(type="readers.las", filename="foo")
        assert rs.streamable is True
        assert pdal.Reader.las("foo").streamable is True
        assert pdal.Reader("foo.las").streamable is True

        rn = pdal.Reader(type="readers.pts", filename="foo")
        assert rn.streamable is False
        assert pdal.Reader.pts("foo").streamable is False
        assert pdal.Reader("foo.pts").streamable is False

        fs = pdal.Filter(type="filters.crop")
        assert fs.streamable is True
        assert pdal.Filter.crop().streamable is True

        fn = pdal.Filter(type="filters.cluster")
        assert fn.streamable is False
        assert pdal.Filter.cluster().streamable is False

        ws = pdal.Writer(type="writers.ogr", filename="foo")
        assert ws.streamable is True
        assert pdal.Writer.ogr(filename="foo").streamable is True
        assert pdal.Writer("foo.shp").streamable is True

        wn = pdal.Writer(type="writers.glb", filename="foo")
        assert wn.streamable is False
        assert pdal.Writer.gltf("foo").streamable is False
        assert pdal.Writer("foo.glb").streamable is False

        assert (rs | fs | ws).streamable is True
        assert (rn | fs | ws).streamable is False
        assert (rs | fn | ws).streamable is False
        assert (rs | fs | wn).streamable is False
Example #2
0
 def test_infer_stage_type(self):
     """Can we infer stage type from the filename"""
     assert pdal.Reader("foo.las").type == "readers.las"
     assert pdal.Writer("foo.las").type == "writers.las"
     assert pdal.Reader("foo.xxx").type == ""
     assert pdal.Writer("foo.xxx").type == ""
     assert pdal.Reader().type == ""
     assert pdal.Writer().type == ""
Example #3
0
 def test_filters_python(self):
     r = pdal.Reader("test/data/autzen-utm.las")
     f = pdal.Filter.python(script=__file__,
                            function="a_filter",
                            module="anything")
     count = (r | f).execute()
     assert count == 1065
Example #4
0
    def test_inputs(self):
        """Can we combine pipelines with inputs"""
        data = np.load(os.path.join(DATADIRECTORY, "test3d.npy"))
        f = pdal.Filter.splitter(length=1000)
        pipeline = f.pipeline(data)
        pipeline.execute()

        # a pipeline with inputs can be followed by stage/pipeline
        (pipeline | pdal.Writer.null()).execute()
        (pipeline | (f | pdal.Writer.null())).execute()

        # a pipeline with inputs cannot follow another stage/pipeline
        with pytest.raises(ValueError):
            pdal.Reader("r") | pipeline
        with pytest.raises(ValueError):
            (pdal.Reader("r") | f) | pipeline
Example #5
0
    def test_construction(self, filename):
        """Can we construct a PDAL pipeline"""
        assert isinstance(get_pipeline(filename), pdal.Pipeline)

        # construct Pipeline from a sequence of stages
        r = pdal.Reader("r")
        f = pdal.Filter("f")
        for spec in (r, f), [r, f]:
            p = pdal.Pipeline(spec)
            assert isinstance(p, pdal.Pipeline)
            assert len(p.stages) == 2
Example #6
0
    def test_only_readers(self):
        """Does a pipeline that consists of only readers return the merged data"""
        read = pdal.Reader("test/data/*.las")
        r1 = read.pipeline()
        count1 = r1.execute()
        array1 = r1.arrays[0]

        r2 = read | read
        count2 = r2.execute()
        array2 = r2.arrays[0]

        assert count2 == 2 * count1
        np.testing.assert_array_equal(np.concatenate([array1, array1]), array2)
Example #7
0
    def test_stages(self, filename):
        """Can we break up a pipeline as a sequence of stages"""
        stages = pdal.Reader("test/data/autzen-utm.las").pipeline().stages
        assert len(stages) == 1

        stages = get_pipeline(filename).stages
        assert len(stages) == 3

        assert isinstance(stages[0], pdal.Reader)
        assert stages[0].type == "readers.las"

        assert isinstance(stages[1], pdal.Filter)
        assert stages[1].type == "filters.chipper"

        assert isinstance(stages[2], pdal.Writer)
        assert stages[2].type == "writers.las"
Example #8
0
    def test_pipe_stage_errors(self):
        """Do we complain with piping invalid objects"""
        r = pdal.Reader("r", tag="r")
        f = pdal.Filter("f")
        w = pdal.Writer("w", inputs=["r", f])

        with pytest.raises(TypeError):
            r | (f, w)
        with pytest.raises(TypeError):
            (r, f) | w
        with pytest.raises(TypeError):
            (r, f) | (f, w)

        pipeline = r | w
        with pytest.raises(RuntimeError) as info:
            pipeline.execute()
        assert "Undefined stage 'f'" in str(info.value)
Example #9
0
    def test_pipe_stages(self):
        """Can we build a pipeline by piping stages together"""
        read = pdal.Reader("test/data/autzen-utm.las")
        frange = pdal.Filter.range(limits="Intensity[50:200)")
        fsplitter = pdal.Filter.splitter(length=1000)
        fdelaunay = pdal.Filter.delaunay(inputs=[frange, fsplitter])

        # pipe stages together
        pipeline = read | frange | fsplitter | fdelaunay
        pipeline.execute()

        # pipe a pipeline to a stage
        pipeline = read | (frange | fsplitter | fdelaunay)
        pipeline.execute()

        # pipe a pipeline to a pipeline
        pipeline = (read | frange) | (fsplitter | fdelaunay)
        pipeline.execute()
Example #10
0
 def test_quickinfo(self):
     r = pdal.Reader("test/data/autzen-utm.las")
     p = r.pipeline()
     info = p.quickinfo
     assert 'readers.las' in info.keys()
     assert info['readers.las']['num_points'] == 1065