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

Function runOgrWriterInfo

test/unit/io/OGRWriterTest.cpp:56–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54{
55
56void runOgrWriterInfo(const Options& wo, const std::string& infile,
57 const std::string& infofile, const std::string suffix, int featureCount = 10,
58 uint32_t(*compare)(const std::string&, const std::string&, int32_t) = &Support::diff_text_files
59)
60{
61 FileUtils::createDirectory(Support::temppath("ogr"));
62 std::string outfile(Support::temppath(std::string("ogr/") + FileUtils::stem(FileUtils::stem(FileUtils::getFilename(infofile))) + suffix));
63 std::string outinfofile(outfile + ".ogrinfo");
64
65 if(FileUtils::isDirectory(outfile)) {
66 FileUtils::deleteDirectory(outfile);
67 } else {
68 FileUtils::deleteFile(outfile);
69 }
70 FileUtils::deleteFile(outinfofile);
71
72 Options readerOpts;
73 readerOpts.add("filename", infile);
74
75 LasReader reader;
76 reader.setOptions(readerOpts);
77
78 Options sortOpts;
79 SortFilter sortFilter;
80 sortOpts.add("dimension", "X");
81 sortFilter.setOptions(sortOpts);
82 sortFilter.setInput(reader);
83
84 Options writerOpts;
85 writerOpts.add("filename", outfile);
86
87 OGRWriter writer;
88 writer.setOptions(wo);
89 writer.addOptions(writerOpts);
90
91 HeadFilter headFilter;
92 if (featureCount > 0) {
93 Options headOpts;
94 headOpts.add("count", featureCount);
95 headFilter.setOptions(headOpts);
96 headFilter.setInput(sortFilter);
97 writer.setInput(headFilter);
98 } else {
99 writer.setInput(sortFilter);
100 }
101
102 PointTable t;
103 writer.prepare(t);
104 writer.execute(t);
105
106 std::string cmd = "ogrinfo -nomd -al " + outfile;
107 if (featureCount == 0) {
108 cmd += " -so";
109 }
110 cmd += " 2>&1";
111 std::string info;
112 if (Utils::run_shell_command(cmd, info)) {
113 std::cerr << "WARNING: error running ogrinfo, skipping test" << std::endl;

Callers 1

TESTFunction · 0.85

Calls 14

createDirectoryFunction · 0.85
temppathFunction · 0.85
stemFunction · 0.85
getFilenameFunction · 0.85
isDirectoryFunction · 0.85
deleteDirectoryFunction · 0.85
deleteFileFunction · 0.85
setOptionsMethod · 0.80
createFileFunction · 0.50
closeFileFunction · 0.50
compareFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected