snake_order_test.cpp
Go to the documentation of this file.
1 //=============================================================================
2 // Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 // Author: Gonzalo Mier
4 // BSD-3 License
5 //=============================================================================
6 
7 #include <gtest/gtest.h>
8 #include "fields2cover/types.h"
11 
12 TEST(fields2cover_route_snake, genSortedSwaths_even) {
13  const int n = 11;
15  for (int i = 1; i < n; ++i) {
16  swaths.emplace_back(F2CLineString({F2CPoint(0, i), F2CPoint(1, i)}), i, i);
17  }
18 
19  f2c::rp::SnakeOrder swath_sorter;
21 
22  swaths = swath_sorter.genSortedSwaths(swaths);
23 
24  EXPECT_EQ(swaths[0].getWidth(), 1);
25  EXPECT_EQ(swaths[1].getWidth(), 3);
26  EXPECT_EQ(swaths[2].getWidth(), 5);
27  EXPECT_EQ(swaths.back().getWidth(), 2);
28 
29  EXPECT_EQ(objective.computeCost(swaths), 3*((n-1)-1));
30 }
31 
32 
33 TEST(fields2cover_route_snake, genSortedSwaths_odd) {
34  const int n = 100;
36  for (int i = 1; i < n; ++i) {
37  swaths.emplace_back(F2CLineString({F2CPoint(0, i), F2CPoint(1, i)}), i, i);
38  }
39 
40  f2c::rp::SnakeOrder swath_sorter;
42 
43  swaths = swath_sorter.genSortedSwaths(swaths);
44 
45  EXPECT_EQ(swaths[0].getWidth(), 1);
46  EXPECT_EQ(swaths[1].getWidth(), 3);
47  EXPECT_EQ(swaths[2].getWidth(), 5);
48  EXPECT_EQ(swaths.back().getWidth(), 2);
49  EXPECT_EQ(objective.computeCost(swaths), 3*((n-1)-1));
50 }
51 
snake_order.h
5_route_planning.swaths
swaths
Definition: 5_route_planning.py:58
f2c::rp::SnakeOrder
Definition: snake_order.h:16
types.h
f2c::obj::DirectDistPathObj
Path cost function as the straight distance between points in a route.
Definition: direct_dist_path_obj.h:17
TEST
TEST(fields2cover_route_snake, genSortedSwaths_even)
Definition: snake_order_test.cpp:12
f2c::rp::SingleCellSwathsOrderBase::genSortedSwaths
virtual F2CSwaths genSortedSwaths(const F2CSwaths &swaths, uint32_t variant=0) const
Definition: single_cell_swaths_order_base.cpp:12
F2CLineString
f2c::types::LineString F2CLineString
Definition: types.h:40
direct_dist_path_obj.h
f2c::obj::DirectDistPathObj::computeCost
double computeCost(const F2CPoint &p1, const F2CPoint &p2) override
Definition: direct_dist_path_obj.cpp:11
f2c::types::Swaths
Definition: Swaths.h:20
F2CPoint
f2c::types::Point F2CPoint
Definition: types.h:38


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31