MCPcopy Create free account
hub / github.com/PDAL/PDAL / compare_contents

Function compare_contents

plugins/nitf/test/NitfWriterTest.cpp:51–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49{
50
51void compare_contents(const std::string& las_file, const std::string& ntf_file)
52{
53 //
54 // read the LAS file
55 //
56 Option las_opt("filename", las_file);
57 Options las_opts;
58 las_opts.add(las_opt);
59
60 PointTable lasPoints;
61
62 StageFactory f;
63
64 Stage* las_reader(f.createStage("readers.las"));
65 EXPECT_TRUE(las_reader);
66 las_reader->setOptions(las_opts);
67 las_reader->prepare(lasPoints);
68 PointViewSet lasViews = las_reader->execute(lasPoints);
69 EXPECT_EQ(lasViews.size(), 1u);
70 PointViewPtr lasView = *lasViews.begin();
71
72 //
73 // read the NITF file
74 //
75 Option ntf_opt("filename", ntf_file);
76 Options ntf_opts;
77 ntf_opts.add(ntf_opt);
78
79 PointTable ntfPoints;
80 Stage* ntf_reader(f.createStage("readers.nitf"));
81 EXPECT_TRUE(ntf_reader);
82 ntf_reader->setOptions(ntf_opts);
83 ntf_reader->prepare(ntfPoints);
84 PointViewSet ntfViews = ntf_reader->execute(ntfPoints);
85 EXPECT_EQ(ntfViews.size(), 1u);
86 PointViewPtr ntfView = *ntfViews.begin();
87
88 MetadataNode root = ntf_reader->getMetadata();
89 MetadataNode n = root.findChild("FH.FTITLE");
90 EXPECT_EQ(n.value(), "LiDAR from somewhere");
91 n = root.findChild("FH.ONAME");
92 EXPECT_EQ(n.value(), "Howard Butler");
93 n = root.findChild("FH.OPHONE");
94 EXPECT_EQ(n.value(), "5155554628");
95 n = root.findChild([](MetadataNode& m)
96 { return m.name() == "IM:0.IDATIM"; }
97 );
98 EXPECT_EQ(n.value(), "20110516183337");
99
100 //
101 // compare the two views
102 //
103 EXPECT_EQ(ntfView->size(), lasView->size());
104
105 for (PointId i = 0; i < ntfView->size(); ++i)
106 {
107 EXPECT_DOUBLE_EQ(ntfView->getFieldAs<double>(Dimension::Id::X, i),
108 lasView->getFieldAs<double>(Dimension::Id::X, i));

Callers 1

TESTFunction · 0.85

Calls 10

createStageMethod · 0.80
setOptionsMethod · 0.80
addMethod · 0.45
prepareMethod · 0.45
executeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
getMetadataMethod · 0.45
valueMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected