|
| 1 | +#include <CesiumGeospatial/BoundingRegion.h> |
1 | 2 | #include <CesiumGeospatial/BoundingRegionBuilder.h> |
2 | 3 | #include <CesiumGeospatial/Ellipsoid.h> |
3 | 4 | #include <CesiumGeospatial/GlobeRectangle.h> |
@@ -183,3 +184,107 @@ TEST_CASE("BoundingRegionBuilder::expandToIncludeGlobeRectangle") { |
183 | 184 | Math::Epsilon15)); |
184 | 185 | } |
185 | 186 | } |
| 187 | + |
| 188 | +TEST_CASE("BoundingRegionBuilder::expandToIncludeBoundingRegion") { |
| 189 | + SUBCASE("expands to include rectangle") { |
| 190 | + BoundingRegionBuilder builder; |
| 191 | + bool modified = builder.expandToIncludeBoundingRegion( |
| 192 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0)); |
| 193 | + BoundingRegion region = builder.toRegion(); |
| 194 | + CHECK(BoundingRegion::equalsEpsilon( |
| 195 | + region, |
| 196 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0), |
| 197 | + Math::Epsilon15)); |
| 198 | + CHECK(modified); |
| 199 | + |
| 200 | + SUBCASE("does nothing if the rectangle is already included") { |
| 201 | + modified = builder.expandToIncludeBoundingRegion( |
| 202 | + BoundingRegion(GlobeRectangle(0.15, 0.25, 0.25, 0.35), -1.0, 2.0)); |
| 203 | + region = builder.toRegion(); |
| 204 | + CHECK(BoundingRegion::equalsEpsilon( |
| 205 | + region, |
| 206 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0), |
| 207 | + Math::Epsilon15)); |
| 208 | + CHECK_FALSE(modified); |
| 209 | + } |
| 210 | + |
| 211 | + SUBCASE("expands if rectangle is not included") { |
| 212 | + modified = builder.expandToIncludeBoundingRegion( |
| 213 | + BoundingRegion(GlobeRectangle(0.05, 0.15, 0.35, 0.45), -1.0, 2.0)); |
| 214 | + region = builder.toRegion(); |
| 215 | + CHECK(BoundingRegion::equalsEpsilon( |
| 216 | + region, |
| 217 | + BoundingRegion(GlobeRectangle(0.05, 0.15, 0.35, 0.45), -1.0, 2.0), |
| 218 | + Math::Epsilon15)); |
| 219 | + CHECK(modified); |
| 220 | + } |
| 221 | + } |
| 222 | + |
| 223 | + SUBCASE("expands to include min height") { |
| 224 | + BoundingRegionBuilder builder; |
| 225 | + bool modified = builder.expandToIncludeBoundingRegion( |
| 226 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0)); |
| 227 | + BoundingRegion region = builder.toRegion(); |
| 228 | + CHECK(BoundingRegion::equalsEpsilon( |
| 229 | + region, |
| 230 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0), |
| 231 | + Math::Epsilon15)); |
| 232 | + CHECK(modified); |
| 233 | + |
| 234 | + SUBCASE("does nothing if min height is already included") { |
| 235 | + modified = builder.expandToIncludeBoundingRegion( |
| 236 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -0.5, 2.0)); |
| 237 | + region = builder.toRegion(); |
| 238 | + CHECK(BoundingRegion::equalsEpsilon( |
| 239 | + region, |
| 240 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0), |
| 241 | + Math::Epsilon15)); |
| 242 | + CHECK_FALSE(modified); |
| 243 | + } |
| 244 | + |
| 245 | + SUBCASE("expands to include min height") { |
| 246 | + modified = builder.expandToIncludeBoundingRegion( |
| 247 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.5, 2.0)); |
| 248 | + region = builder.toRegion(); |
| 249 | + CHECK(BoundingRegion::equalsEpsilon( |
| 250 | + region, |
| 251 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.5, 2.0), |
| 252 | + Math::Epsilon15)); |
| 253 | + CHECK(modified); |
| 254 | + } |
| 255 | + } |
| 256 | + |
| 257 | + SUBCASE("expands to include max height") { |
| 258 | + BoundingRegionBuilder builder; |
| 259 | + bool modified = builder.expandToIncludeBoundingRegion( |
| 260 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0)); |
| 261 | + BoundingRegion region = builder.toRegion(); |
| 262 | + CHECK(BoundingRegion::equalsEpsilon( |
| 263 | + region, |
| 264 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0), |
| 265 | + Math::Epsilon15)); |
| 266 | + CHECK(modified); |
| 267 | + |
| 268 | + SUBCASE("does nothing if max height is already included") { |
| 269 | + modified = builder.expandToIncludeBoundingRegion( |
| 270 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 1.5)); |
| 271 | + region = builder.toRegion(); |
| 272 | + CHECK(BoundingRegion::equalsEpsilon( |
| 273 | + region, |
| 274 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0), |
| 275 | + Math::Epsilon15)); |
| 276 | + CHECK_FALSE(modified); |
| 277 | + } |
| 278 | + |
| 279 | + SUBCASE("expands to include max height") { |
| 280 | + modified = builder.expandToIncludeBoundingRegion( |
| 281 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.5)); |
| 282 | + region = builder.toRegion(); |
| 283 | + CHECK(BoundingRegion::equalsEpsilon( |
| 284 | + region, |
| 285 | + BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.5), |
| 286 | + Math::Epsilon15)); |
| 287 | + CHECK(modified); |
| 288 | + } |
| 289 | + } |
| 290 | +} |
0 commit comments