Beispiel #1
0
TEST(RangeFilterTest, stream_logic)
{
    Options ops;
    ops.add("bounds", BOX3D(1, 101, 201, 10, 110, 210));
    ops.add("mode", "ramp");
    ops.add("count", 10);

    FauxReader reader;
    reader.setOptions(ops);

    Options rangeOps;
    rangeOps.add("limits", "Y[108:109], X[2:5], Z[1:1000], X[7:9], Y[103:105]");

    RangeFilter range;
    range.setOptions(rangeOps);
    range.setInput(reader);

    StreamCallbackFilter f;
    f.setInput(range);

    FixedPointTable table(20);
    f.prepare(table);

    auto cb = [](PointRef& point)
    {
        static int i = 0;
        int x = point.getFieldAs<int>(Dimension::Id::X);
        if (i == 0)
            EXPECT_EQ(x, 3);
        else if (i == 1)
            EXPECT_EQ(x, 4);
        else if (i == 2)
            EXPECT_EQ(x, 5);
        else if (i == 3)
            EXPECT_EQ(x, 8);
        else if (i == 4)
            EXPECT_EQ(x, 9);
        EXPECT_TRUE(i < 5);
        ++i;
        return true;
    };
    f.setCallback(cb);

    f.execute(table);
}
// Test reprojecting UTM 15 to DD with a filter
TEST(ReprojectionFilterTest, stream_test_1)
{
    const char* epsg4326_wkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]";


    Options ops1;
    ops1.add("filename", Support::datapath("las/utm15.las"));
    LasReader reader;
    reader.setOptions(ops1);

    Options options;
    options.add("out_srs", epsg4326_wkt);

    ReprojectionFilter reprojectionFilter;
    reprojectionFilter.setOptions(options);
    reprojectionFilter.setInput(reader);

    auto cb = [](PointRef& point)
    {
        static int i = 0;
        const double x = -93.351563;
        const double y = 41.577148;
        const double z = 16.000000;

        if (i == 0)
        {
            EXPECT_FLOAT_EQ(point.getFieldAs<float>(Dimension::Id::X), x);
            EXPECT_FLOAT_EQ(point.getFieldAs<float>(Dimension::Id::Y), y);
            EXPECT_FLOAT_EQ(point.getFieldAs<float>(Dimension::Id::Z), z);
        }
        ++i;
        return true;
    };

    StreamCallbackFilter stream;
    stream.setCallback(cb);
    stream.setInput(reprojectionFilter);

    FixedPointTable table(20);

    stream.prepare(table);
    stream.execute(table);
}
Beispiel #3
0
TEST(FerryFilterTest, stream)
{
    FauxReader r;

    Options ro;
    ro.add("mode", "ramp");
    ro.add("bounds", BOX3D(0, 0, 0, 99, 99, 99));
    ro.add("num_points", 100);

    r.setOptions(ro);

    Options fo;
    fo.add("dimensions", "X=FooX,Y=BarY");

    FerryFilter f;
    f.setOptions(fo);
    f.setInput(r);

    StreamCallbackFilter c;
    c.setInput(f);

    FixedPointTable t(10);
    c.prepare(t);

    auto foox = t.layout()->findDim("FooX");
    auto fooy = t.layout()->findDim("BarY");
    auto cb = [foox,fooy](PointRef& point)
    {
        static int i = 0;
        EXPECT_EQ(point.getFieldAs<int>(Dimension::Id::X),
            point.getFieldAs<int>(foox));
        EXPECT_EQ(point.getFieldAs<int>(Dimension::Id::Y),
            point.getFieldAs<int>(fooy));
        EXPECT_EQ(i, point.getFieldAs<int>(foox));
        ++i;
        return true;
    };
    c.setCallback(cb);

    c.execute(t);
}
Beispiel #4
0
TEST(DecimationFilterTest, stream)
{
    BOX3D srcBounds(0.0, 0.0, 0.0, 99.0, 99.0, 99.0);

    Options ops;
    ops.add("bounds", srcBounds);
    ops.add("mode", "ramp");
    ops.add("num_points", 100);
    FauxReader reader;
    reader.setOptions(ops);

    Options decimationOps;
    decimationOps.add("step", 10);
    decimationOps.add("offset", 10);
    decimationOps.add("limit", 90);

    DecimationFilter dec;
    dec.setOptions(decimationOps);
    dec.setInput(reader);

    StreamCallbackFilter filter;

    auto cb = [](PointRef& point)
    {
        static int i = 0;
        int x = point.getFieldAs<int>(Dimension::Id::X);
        int y = point.getFieldAs<int>(Dimension::Id::Y);
        EXPECT_EQ(x, (i + 1) * 10);
        EXPECT_EQ(y, (i + 1) * 10);
        EXPECT_TRUE(i < 8);
        i++;
        return true;
    };
    filter.setCallback(cb);
    filter.setInput(dec);

    FixedPointTable t(2);

    filter.prepare(t);
    filter.execute(t);
}
Beispiel #5
0
TEST(ColorinterpFilterTest, minmax)
{
    FauxReader f;
    Options options;

    options.add("count", 100);
    options.add("mode", "ramp");
    options.add("bounds", "([0,99],[0,99],[0,99])");

    f.setOptions(options);

    ColorinterpFilter c;
    Options coptions;

    coptions.add("minimum", 0);
    coptions.add("maximum", 99);
    coptions.add("ramp", makeColor());

    c.setOptions(coptions);

    StreamCallbackFilter s;

    c.setInput(f);
    s.setInput(c);

    auto cb  = [](PointRef& point)
    {
        int z = point.getFieldAs<int>(Dimension::Id::Z);
        int r = point.getFieldAs<int>(Dimension::Id::Red);
        int g = point.getFieldAs<int>(Dimension::Id::Green);
        int b = point.getFieldAs<int>(Dimension::Id::Blue);

        if (z != 99)
            EXPECT_EQ((int)(z / 25) + 1, r);
        if (z == 99)
            EXPECT_EQ(0, r);
        EXPECT_EQ(0, g);
        EXPECT_EQ(0, b);

        return true;
    };

    s.setCallback(cb);

    FixedPointTable t(10);
    s.prepare(t);
    s.execute(t);

    PointTable t2;

    s.prepare(t2);
    s.execute(t2);
}
Beispiel #6
0
TEST(CropFilterTest, stream)
{
    using namespace Dimension;

    FixedPointTable table(2);
    table.layout()->registerDim(Id::X);
    table.layout()->registerDim(Id::Y);
    table.layout()->registerDim(Id::Z);

    class StreamReader : public Reader
    {
    public:
        std::string getName() const
            { return "readers.stream"; }
        bool processOne(PointRef& point)
        {
            static int i = 0;

            if (i == 0)
            {
                point.setField(Id::X, 2);
                point.setField(Id::Y, 2);
            }
            else if (i == 1)
            {
                point.setField(Id::X, 6);
                point.setField(Id::Y, 2);
            }
            else if (i == 2)
            {
                point.setField(Id::X, 8);
                point.setField(Id::Y, 2);
            }
            else if (i == 3)
            {
                point.setField(Id::X, 10);
                point.setField(Id::Y, 2);
            }
            else if (i == 4)
            {
                point.setField(Id::X, 12);
                point.setField(Id::Y, 2);
            }
            else
                return false;
            i++;
            return true;
        }
    };

    StreamReader r;

    CropFilter crop;
    Options o;
    o.add("bounds", "([1, 3], [1, 3])");
    o.add("bounds", "([5, 7], [1, 3])");
    o.add("polygon", "POLYGON ((9 1, 11 1, 11 3, 9 3, 9 1))");
    crop.setInput(r);
    crop.setOptions(o);

    auto cb = [](PointRef& point)
    {
        static int i = 0;
        if (i == 0)
        {
            EXPECT_EQ(point.getFieldAs<int>(Id::X), 2);
            EXPECT_EQ(point.getFieldAs<int>(Id::Y), 2);
        }
        if (i == 1)
        {
            EXPECT_EQ(point.getFieldAs<int>(Id::X), 6);
            EXPECT_EQ(point.getFieldAs<int>(Id::Y), 2);
        }
        if (i == 2)
        {
            EXPECT_EQ(point.getFieldAs<int>(Id::X), 10);
            EXPECT_EQ(point.getFieldAs<int>(Id::Y), 2);
        }
        else
            return false;
        i++;
        return true;
    };

    StreamCallbackFilter f;
    f.setCallback(cb);
    f.setInput(crop);

    f.prepare(table);
    f.execute(table);
}