Skip to content

Commit

Permalink
Remove ept:// as protocol.
Browse files Browse the repository at this point in the history
Add test.
  • Loading branch information
abellgithub committed May 13, 2020
1 parent 3c0d315 commit d1d4c7e
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 12 deletions.
9 changes: 4 additions & 5 deletions pdal/StageFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace pdal
namespace
{

const std::vector<std::string> protocols { "ept", "i3s" };
const std::vector<std::string> protocols { "i3s" };

std::string getDriverProtocol(std::string filename)
{
Expand Down Expand Up @@ -74,8 +74,10 @@ std::string StageFactory::inferReaderDriver(const std::string& filename)
{
std::string ext;

const std::string driverProtocol = getDriverProtocol(filename);
if (Utils::endsWith(filename, "ept.json"))
return "readers.ept";

const std::string driverProtocol = getDriverProtocol(filename);
if (!driverProtocol.empty())
ext = "." + driverProtocol;
else
Expand All @@ -84,9 +86,6 @@ std::string StageFactory::inferReaderDriver(const std::string& filename)
if (ext.length())
ext = Utils::tolower(ext.substr(1));

if (ext == "json" && Utils::endsWith(filename, "ept.json"))
return "readers.ept";

return PluginManager<Stage>::extensions().defaultReader(ext);
}

Expand Down
109 changes: 102 additions & 7 deletions test/unit/io/EptAddonWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace pdal;
namespace
{
const std::string eptLaszipPath(
Support::datapath("ept/lone-star-laszip/ept.json"));
Support::datapath("ept/lone-star-laszip/ept.json"));
}

TEST(EptAddonWriterTest, fullLoop)
Expand Down Expand Up @@ -99,8 +99,8 @@ TEST(EptAddonWriterTest, fullLoop)
EptAddonWriter writer;
{
NL::json addons;
addons[addonDir + "class/ept.json"] = "Classification";
addons[addonDir + "other/ept.json"] = "Other";
addons[addonDir + "class"] = "Classification";
addons[addonDir + "other"] = "Other";

Options o;
o.add("addons", addons);
Expand All @@ -118,8 +118,8 @@ TEST(EptAddonWriterTest, fullLoop)
EptReader reader;
{
NL::json addons;
addons["Classification"] = addonDir + "class/ept.json";
addons["Other"] = addonDir + "other/ept.json";
addons["Classification"] = addonDir + "class";
addons["Other"] = addonDir + "other";

Options o;
o.add("filename", eptLaszipPath);
Expand Down Expand Up @@ -153,15 +153,14 @@ TEST(EptAddonWriterTest, boundedWrite)
const std::string addonDir(Support::datapath("ept/addon/"));
FileUtils::deleteDirectory(addonDir);

const std::string boundsString("([515380, 515400], [4918350, 4918370])");
BOX2D bounds(515380, 4918350, 515400, 4918370);

{
EptReader reader;
{
Options o;
o.add("filename", eptLaszipPath);
o.add("bounds", boundsString);
o.add("bounds", bounds);
reader.setOptions(o);
}

Expand Down Expand Up @@ -220,6 +219,8 @@ TEST(EptAddonWriterTest, boundedWrite)
y = view->getFieldAs<double>(Dimension::Id::Y, i);
c = view->getFieldAs<uint8_t>(Dimension::Id::Classification, i);

EXPECT_GT(x, 0);
EXPECT_GT(y, 0);
if (bounds.contains(x, y))
{
++in;
Expand All @@ -239,6 +240,100 @@ TEST(EptAddonWriterTest, boundedWrite)
EXPECT_GT(out, 0);
}

TEST(EptAddonWriterTest, boundedRead)
{
// Make sure that when we query an EPT set using a boundary that it
// looks consistent.

const std::string addonDir(Support::datapath("ept/addon/"));
FileUtils::deleteDirectory(addonDir);

{
EptReader reader;
{
Options o;
o.add("filename", eptLaszipPath);
reader.setOptions(o);
}

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

EptAddonWriter writer;
{
NL::json addons;
addons[addonDir + "bounded"] = "Classification";

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

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

// Now we'll query the whole dataset with this addon - points outside the
// bounds should have a Classification of zero.

BOX2D bounds(515380, 4918300, 515450, 4918370);
EptReader reader;
{
NL::json addons;
addons["Classification"] = addonDir + "bounded";

Options o;
o.add("filename", eptLaszipPath);
o.add("bounds", bounds);
o.add("addons", addons);
reader.setOptions(o);
}

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

double x, y;
uint8_t c;

int in(0), out(0);

for (const PointViewPtr& view : set)
{
for (point_count_t i(0); i < view->size(); ++i)
{
x = view->getFieldAs<double>(Dimension::Id::X, i);
y = view->getFieldAs<double>(Dimension::Id::Y, i);
c = view->getFieldAs<uint8_t>(Dimension::Id::Classification, i);

EXPECT_GT(x, 0);
EXPECT_GT(y, 0);
if (bounds.contains(x, y))
{
++in;
ASSERT_EQ(c, 42u);
}
else
{
++out;
ASSERT_EQ(c, 0u);
}
}
}

// Make sure our bounds are actually selecting data and pruning
// appropriately.
EXPECT_GT(in, 0);
EXPECT_EQ(out, 0);
}

TEST(EptAddonWriterTest, mustDescendFromEptReader)
{
// Make sure the EPT writer throws if it is not used in tandem with an EPT
Expand Down

0 comments on commit d1d4c7e

Please sign in to comment.