@@ -381,11 +381,11 @@ TEST(Viewshed, simple_height)
381381
382382 std::array<double , xlen * ylen> observable
383383 {
384- 4 , 2 , 0 , 4 , 8 ,
384+ 4 , 2 , 1 , 4 , 8 ,
385385 3 , 2 , 0 , 4 , 3 ,
386- 2 , 1 , 0 , -1 , -2 ,
386+ 2 , 1 , 0 , -1 , -1 ,
387387 4 , 3 , 0 , 2 , 1 ,
388- 6 , 3 , 0 , 2 , 4
388+ 6 , 3 , 0 , 3 , 4
389389 };
390390 // clang-format on
391391
@@ -423,11 +423,7 @@ TEST(Viewshed, simple_height)
423423 ylen, GDT_Float64, 0 , 0 , nullptr );
424424 EXPECT_EQ (err, CE_None);
425425
426- // DEM values are observable values clamped at 0. Not sure why.
427426 std::array<double , xlen *ylen> expected = observable;
428- for (double &d : expected)
429- d = std::max (0.0 , d);
430-
431427 // Double equality is fine here as all the values are small integers.
432428 EXPECT_EQ (dem, expected);
433429 }
@@ -489,18 +485,18 @@ TEST(Viewshed, dem_vs_ground)
489485 EXPECT_DOUBLE_EQ (out[i], dem[i]);
490486 };
491487
492- // Input / Observer / Minimum expected above ground / Minimum expected above zero
488+ // Input / Observer / Minimum expected above ground / Minimum expected above zero (DEM)
493489 run ({0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 }, {2 , 0 }, {0 , 0 , 0 , 0 , 2 , 3 , 4 , 5 },
494490 {0 , 0 , 0 , 1 , 2 , 3 , 4 , 5 });
495491 run ({1 , 1 , 0 , 1 , 0 , 1 , 2 , 2 }, {3 , 0 }, {0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 / 3.0 },
496- {1 , 0 , 0 , 1 , 0 , 0 , 1 , 7 / 3.0 });
492+ {1 , 1 , 0 , 1 , 0 , 1 , 2 , 7 / 3.0 });
497493 run ({0 , 0 , 0 , 1 , 1 , 0 , 0 , 0 }, {0 , 0 },
498494 {0 , 0 , 0 , 0 , 1 / 3.0 , 5 / 3.0 , 6 / 3.0 , 7 / 3.0 },
499- {0 , 0 , 0 , 0 , 4 / 3.0 , 5 / 3.0 , 6 / 3.0 , 7 / 3.0 });
495+ {0 , 0 , 0 , 1 , 4 / 3.0 , 5 / 3.0 , 6 / 3.0 , 7 / 3.0 });
500496 run ({0 , 0 , 1 , 2 , 3 , 4 , 5 , 6 }, {0 , 0 }, {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
501- {0 , 0 , 0 , 3 / 2.0 , 8 / 3.0 , 15 / 4.0 , 24 / 5.0 , 35 / 6.0 });
497+ {0 , 0 , 1 , 2 , 3 , 4 , 5 , 6 });
502498 run ({0 , 0 , 1 , 1 , 3 , 4 , 5 , 4 }, {0 , 0 }, {0 , 0 , 0 , .5 , 0 , 0 , 0 , 11 / 6.0 },
503- {0 , 0 , 0 , 3 / 2.0 , 2 , 15 / 4.0 , 24 / 5.0 , 35 / 6.0 });
499+ {0 , 0 , 1 , 1.5 , 3 , 4 , 5 , 35 / 6.0 });
504500}
505501
506502// Test an observer to the right of the raster.
@@ -530,8 +526,8 @@ TEST(Viewshed, oor_right)
530526 // clang-format off
531527 std::array<double , xlen * ylen> expected
532528 {
533- 16 / 3.0 , 29 / 6.0 , 13 / 3.0 , 1 , 1 ,
534- 3 , 2.5 , 4 / 3.0 , 0 , 0 ,
529+ 16 / 3.0 , 29 / 6.0 , 13 / 3.0 , 4 , 1 ,
530+ 3 , 2.5 , 2 , 1 , 0 ,
535531 13 / 3.0 , 23 / 6.0 , 10 / 3.0 , 3 , 3
536532 };
537533 // clang-format on
@@ -553,7 +549,7 @@ TEST(Viewshed, oor_right)
553549 // clang-format off
554550 std::array<double , xlen * ylen> expected
555551 {
556- 26 / 5.0 , 17 / 4.0 , 11 / 3.0 , . 5 , 1 ,
552+ 26 / 5.0 , 17 / 4.0 , 11 / 3.0 , 4 , 1 ,
557553 6 , 4.5 , 3 , 1.5 , 0 ,
558554 9 , 7.5 , 6 , 4.5 , 3
559555 };
@@ -591,9 +587,9 @@ TEST(Viewshed, oor_left)
591587 // clang-format off
592588 std::array<double , xlen * ylen> expected
593589 {
594- 1 , 1 , 2 , 2.5 , 4.5 ,
595- 0 , 0 , 0 , 2.5 , 3 ,
596- 1 , 1 , 1 , 1.5 , 3.5
590+ 1 , 2 , 2 , 4 , 4.5 ,
591+ 0 , 0 , 2 , 2.5 , 3 ,
592+ 1 , 1 , 1 , 3 , 3.5
597593 };
598594 // clang-format on
599595
@@ -614,9 +610,9 @@ TEST(Viewshed, oor_left)
614610 // clang-format off
615611 std::array<double , xlen * ylen> expected
616612 {
617- 1 , . 5 , 5 / 3.0 , 2.25 , 4.2 ,
618- 0 , .5 , 1 , 2.5 , 3.1 ,
619- 1 , 1.5 , 2 , 2.5 , 3.6
613+ 1 , 2 , 5 / 3.0 , 4 , 4.2 ,
614+ 0 , .5 , 2 , 2.5 , 3.1 ,
615+ 1 , 1.5 , 2 , 3 , 3.6
620616 };
621617 // clang-format on
622618
@@ -654,7 +650,7 @@ TEST(Viewshed, oor_above)
654650 std::array<double , xlen * ylen> expected
655651 {
656652 1 , 2 , 0 , 4 , 1 ,
657- 2.5 , 2 , 0 , 4 , 4.5 ,
653+ 2.5 , 2 , 2 , 4 , 4.5 ,
658654 3 , 8 / 3.0 , 8 / 3.0 , 14 / 3.0 , 17 / 3.0
659655 };
660656 // clang-format on
@@ -678,7 +674,7 @@ TEST(Viewshed, oor_above)
678674 {
679675 1 , 2 , 0 , 4 , 1 ,
680676 0 , 1.5 , 2.5 , 1.25 , 3.15 ,
681- 1 , 0.5 , 2 , 3 , 2.2
677+ 1 , 0.5 , 2 , 3 , 3
682678 };
683679 // clang-format on
684680
@@ -715,9 +711,9 @@ TEST(Viewshed, oor_below)
715711 // clang-format off
716712 std::array<double , xlen * ylen> expected
717713 {
718- 1 / 3.0 , 2 / 3.0 , 8 / 3.0 , 11 / 3.0 , 5 ,
719- 0.5 , 0 , 0 , 3 , 4.5 ,
720- 1 , 0 , 0 , 3 , 3
714+ 1 , 2 , 8 / 3.0 , 4 , 5 ,
715+ 0.5 , 0 , 2 , 3 , 4.5 ,
716+ 1 , 0 , 0 , 3 , 3
721717 };
722718 // clang-format on
723719
@@ -738,7 +734,7 @@ TEST(Viewshed, oor_below)
738734 // clang-format off
739735 std::array<double , xlen * ylen> expected
740736 {
741- 4.2 , 6 , 6 , 1.5 , 1 ,
737+ 4.2 , 6 , 6 , 4 , 1 ,
742738 1.35 , 2.25 , 4.5 , 4.5 , 0 ,
743739 1 , 0 , 0 , 3 , 3
744740 };
0 commit comments