| 54 | { |
| 55 | |
| 56 | void 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; |
no test coverage detected