| 54 | { |
| 55 | |
| 56 | void runGdalWriter(const Options& wo, const std::string& infile, |
| 57 | const std::string& outfile, const std::string& values, bool noStream=false, |
| 58 | int bandNum=1) |
| 59 | { |
| 60 | auto run = [=](bool streamMode) |
| 61 | { |
| 62 | FileUtils::deleteFile(outfile); |
| 63 | |
| 64 | Options ro; |
| 65 | ro.add("filename", infile); |
| 66 | |
| 67 | TextReader r; |
| 68 | r.setOptions(ro); |
| 69 | |
| 70 | GDALWriter w; |
| 71 | w.setOptions(wo); |
| 72 | w.setInput(r); |
| 73 | |
| 74 | if (streamMode) |
| 75 | { |
| 76 | FixedPointTable t(100); |
| 77 | |
| 78 | w.prepare(t); |
| 79 | w.execute(t); |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | PointTable t; |
| 84 | |
| 85 | w.prepare(t); |
| 86 | w.execute(t); |
| 87 | } |
| 88 | |
| 89 | Utils::IStringStreamClassicLocale iss(values); |
| 90 | |
| 91 | std::vector<double> arr; |
| 92 | while (true) |
| 93 | { |
| 94 | double d; |
| 95 | iss >> d; |
| 96 | if (!iss) |
| 97 | break; |
| 98 | arr.push_back(d); |
| 99 | } |
| 100 | |
| 101 | gdal::Raster raster(outfile, "GTiff"); |
| 102 | if (raster.open() != gdal::GDALError::None) |
| 103 | { |
| 104 | throw pdal_error(raster.errorMsg()); |
| 105 | } |
| 106 | std::vector<double> data; |
| 107 | raster.readBand(data, bandNum); |
| 108 | int row = 0; |
| 109 | int col = 0; |
| 110 | |
| 111 | for (size_t i = 0; i < arr.size(); ++i) |
| 112 | { |
| 113 | EXPECT_NEAR(arr[i], data[i], .001) << "Error row/col = " << |
no test coverage detected