Пример #1
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);
}
Пример #2
0
TEST(EptAddonWriterTest, fullLoop)
{
    // Test the writing, and subsequent reading, of EPT addons from both
    // well-known and proprietary dimensions.
    const std::string addonDir(Support::datapath("ept/addon/"));
    FileUtils::deleteDirectory(addonDir);

    // First write the output.
    {
        EptReader reader;
        {
            Options o;
            o.add("filename", "ept://" + Support::datapath("ept/ept-star"));
            reader.setOptions(o);
        }

        // Assign Classification values.
        AssignFilter assign1;
        {
            Options o;
            o.add("assignment", "Classification[:]=42");
            assign1.setOptions(o);
            assign1.setInput(reader);
        }

        // Ferry Classification => Other to create a new dimension that we can
        // access in the next step.
        FerryFilter ferry;
        {
            Options o;
            o.add("dimensions", "Classification => Other");
            ferry.setOptions(o);
            ferry.setInput(assign1);
        }

        // Assign proprietary dimension values.
        AssignFilter assign2;
        {
            Options o;
            o.add("assignment", "Other[:]=88");
            assign2.setOptions(o);
            assign2.setInput(ferry);
        }

        EptAddonWriter writer;
        {
            NL::json addons;
            addons[addonDir + "class"] = "Classification";
            addons[addonDir + "other"] = "Other";

            Options o;
            o.add("addons", addons);
            writer.setOptions(o);
            writer.setInput(assign2);
        }

        PointTable table;
        writer.prepare(table);
        writer.execute(table);
    }

    // Then read the output, making sure our dimension values are overridden
    // with the addon values.
    EptReader reader;
    {
        NL::json addons;
        addons["Classification"] = addonDir + "class";
        addons["Other"] = addonDir + "other";

        Options o;
        o.add("filename", "ept://" + Support::datapath("ept/ept-star"));
        o.add("addons", addons);
        reader.setOptions(o);
    }

    PointTable table;
    reader.prepare(table);
    const auto set(reader.execute(table));

    const Dimension::Id classDim(Dimension::Id::Classification);
    const Dimension::Id otherDim(table.layout()->findDim("Other"));

    for (const PointViewPtr& view : set)
    {
        for (point_count_t i(0); i < view->size(); ++i)
        {
            ASSERT_EQ(view->getFieldAs<uint16_t>(classDim, i), 42u);
            ASSERT_EQ(view->getFieldAs<uint16_t>(otherDim, i), 88u);
        }
    }
}