| 97 | } // namespace |
| 98 | |
| 99 | TEST(Viewshed, min_max_mask) |
| 100 | { |
| 101 | const int xlen = 15; |
| 102 | const int ylen = 15; |
| 103 | std::array<int8_t, xlen * ylen> in; |
| 104 | in.fill(0); |
| 105 | |
| 106 | SCOPED_TRACE("min_max_mask"); |
| 107 | Options opts(stdOptions(7, 7)); |
| 108 | opts.minDistance = 2; |
| 109 | opts.maxDistance = 6; |
| 110 | |
| 111 | DatasetPtr output = runViewshed(in.data(), xlen, ylen, opts); |
| 112 | |
| 113 | std::array<int8_t, xlen * ylen> out; |
| 114 | GDALRasterBand *band = output->GetRasterBand(1); |
| 115 | |
| 116 | int xOutLen = band->GetXSize(); |
| 117 | int yOutLen = band->GetYSize(); |
| 118 | EXPECT_EQ(xOutLen, 13); |
| 119 | EXPECT_EQ(yOutLen, 13); |
| 120 | |
| 121 | CPLErr err = band->RasterIO(GF_Read, 0, 0, xOutLen, yOutLen, out.data(), |
| 122 | xOutLen, yOutLen, GDT_Int8, 0, 0, nullptr); |
| 123 | EXPECT_EQ(err, CE_None); |
| 124 | |
| 125 | //clang-format off |
| 126 | std::array<int8_t, 13 * 13> expected{ |
| 127 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 128 | 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0, |
| 129 | 0, 0, 0, 127, 127, 127, 127, 127, 127, 127, 0, 0, 0, |
| 130 | 0, 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 0, 0, |
| 131 | 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 0, |
| 132 | 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 0, |
| 133 | 0, 127, 127, 127, 127, 0, 0, 0, 127, 127, 127, 127, 0, |
| 134 | 127, 127, 127, 127, 127, 0, 0, 0, 127, 127, 127, 127, 127, |
| 135 | 0, 127, 127, 127, 127, 0, 0, 0, 127, 127, 127, 127, 0, |
| 136 | 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 0, |
| 137 | 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 0, |
| 138 | 0, 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 0, 0, |
| 139 | 0, 0, 0, 127, 127, 127, 127, 127, 127, 127, 0, 0, 0}; |
| 140 | //clang-format on |
| 141 | |
| 142 | int8_t *o = out.data(); |
| 143 | int8_t *e = expected.data(); |
| 144 | for (size_t i = 0; i < 13 * 13; ++i) |
| 145 | EXPECT_EQ(*e++, *o++); |
| 146 | |
| 147 | /** |
| 148 | int8_t *p = out.data(); |
| 149 | for (int y = 0; y < yOutLen; ++y) |
| 150 | { |
| 151 | for (int x = 0; x < xOutLen; ++x) |
| 152 | { |
| 153 | char c; |
| 154 | if (*p == 0) |
| 155 | c = '*'; |
| 156 | else if (*p == 127) |
nothing calls this directly
no test coverage detected