| 9 | #include "fields2cover/types.h" |
| 10 | |
| 11 | TEST(fields2cover_obj_overlaps, computeCost_cost) { |
| 12 | F2CLineString path1, path2, path3; |
| 13 | double width {2.0}; |
| 14 | path1.addPoint( 0.0, 1.0); |
| 15 | path1.addPoint( 4.0, 1.0); |
| 16 | path2.addPoint( 0.0, 3.0); |
| 17 | path2.addPoint( 4.0, 3.0); |
| 18 | path3.addPoint( 0.0, 2.0); |
| 19 | path3.addPoint( 4.0, 2.0); |
| 20 | F2CSwath swath1(path1, width); |
| 21 | F2CSwath swath2(path2, width); |
| 22 | F2CSwath swath3(path3, width); |
| 23 | |
| 24 | F2CSwaths swaths_no_overlap {swath1,swath2}; |
| 25 | F2CSwaths swaths_overlap_025 {swath1,swath3}; |
| 26 | F2CSwaths swaths_overlap_050_1 {swath1,swath2,swath3}; |
| 27 | F2CSwaths swaths_overlap_050_2 {swath2,swath1,swath3}; |
| 28 | F2CSwaths swaths_overlap_050_3 {swath2,swath2}; |
| 29 | |
| 30 | F2CCell field; |
| 31 | F2CCells fields; |
| 32 | |
| 33 | F2CLinearRing line; |
| 34 | line.addPoint(0, 0); |
| 35 | line.addPoint(4, 0); |
| 36 | line.addPoint(4, 4); |
| 37 | line.addPoint(0, 4); |
| 38 | line.addPoint(0, 0); |
| 39 | field.addRing(line); |
| 40 | fields.addGeometry(field); |
| 41 | |
| 42 | f2c::obj::Overlaps overlap; |
| 43 | |
| 44 | EXPECT_EQ(overlap.computeCost(field, swaths_no_overlap), 0.0); |
| 45 | EXPECT_EQ(overlap.computeCost(fields, swaths_no_overlap), 0.0); |
| 46 | EXPECT_EQ(overlap.computeCostWithMinimizingSign(fields, swaths_no_overlap), 0.0); |
| 47 | |
| 48 | EXPECT_EQ(overlap.computeCost(fields, swaths_overlap_025), 0.25); |
| 49 | EXPECT_EQ(overlap.computeCostWithMinimizingSign(fields, swaths_overlap_025), 0.25); |
| 50 | |
| 51 | EXPECT_EQ(overlap.computeCost(fields, swaths_overlap_050_1), 0.5); |
| 52 | EXPECT_EQ(overlap.computeCostWithMinimizingSign(fields, swaths_overlap_050_1), 0.5); |
| 53 | |
| 54 | EXPECT_EQ(overlap.computeCost(fields, swaths_overlap_050_2), 0.5); |
| 55 | EXPECT_EQ(overlap.computeCostWithMinimizingSign(fields, swaths_overlap_050_2), 0.5); |
| 56 | |
| 57 | EXPECT_EQ(overlap.computeCost(fields, swaths_overlap_050_3), 0.5); |
| 58 | EXPECT_EQ(overlap.computeCostWithMinimizingSign(fields, swaths_overlap_050_3), 0.5); |
| 59 | } |
| 60 | |
| 61 | TEST(fields2cover_obj_overlaps, params_check) { |
| 62 | f2c::obj::Overlaps objective; |
nothing calls this directly
no test coverage detected