src
fields2cover
objectives
sg_obj
overlaps.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 "
fields2cover/objectives/sg_obj/overlaps.h
"
8
9
namespace
f2c::obj
{
10
11
double
Overlaps::computeCost
(
const
F2CCell
& poly,
const
F2CSwaths
&
swaths
) {
12
return
computeCost
(
F2CCells
(poly),
swaths
);
13
}
14
15
double
Overlaps::computeCost
(
const
F2CCells
& poly,
const
F2CSwaths
&
swaths
) {
16
double
area_overlaped {0.0};
17
std::vector<F2CCells> areas;
18
for
(
int
i =
swaths
.size() - 1; i >= 0; --i) {
19
areas.emplace_back(
swaths
[i].areaCovered(poly));
20
for
(
int
j = i + 1; j < areas.size(); ++j) {
21
if
(areas[i].intersects(areas[j])) {
22
area_overlaped +=
F2CCells
(areas[i]).
intersection
(areas[j]).
area
();
23
}
24
}
25
}
26
return
area_overlaped / poly.
area
();
27
}
28
29
30
}
// namespace f2c::obj
31
f2c::types::Geometries::area
double area() const
Compute area of the geometry.
Definition:
Geometries_impl.hpp:14
5_route_planning.swaths
swaths
Definition:
5_route_planning.py:58
f2c::obj::Overlaps::computeCost
double computeCost(const F2CCell &poly, const F2CSwaths &swaths) override
Compute the cost function.
Definition:
overlaps.cpp:11
f2c::types::Cells::intersection
static Cells intersection(const Cell &cell, const Cell &c)
Definition:
Cells.cpp:148
F2CCells
f2c::types::Cells F2CCells
Definition:
types.h:44
f2c::types::Cell
Definition:
Cell.h:32
f2c::obj
Objective algorithms' namespace.
Definition:
base_objective.h:14
overlaps.h
f2c::types::Cells
Definition:
Cells.h:21
f2c::types::Swaths
Definition:
Swaths.h:20
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31