Swath.h
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 #pragma once
8 #ifndef FIELDS2COVER_TYPES_SWATH_H_
9 #define FIELDS2COVER_TYPES_SWATH_H_
10 
11 #include <gdal/ogr_geometry.h>
12 
13 #include <algorithm>
14 #include <memory>
15 #include <utility>
18 
19 namespace f2c::types {
20 
21 enum class SwathType {MAINLAND = 0, HEADLAND = 1};
22 
23 struct Swath {
24  public:
25  Swath();
26  explicit Swath(const LineString& path);
27  explicit Swath(double width);
28  Swath(const LineString& path, double width,
29  int id = 0, SwathType type = SwathType::MAINLAND);
30  Swath(const Swath&);
31  virtual ~Swath();
32  virtual Swath& operator=(Swath&&);
33  virtual Swath& operator=(const Swath&);
34  bool operator!=(const Swath& s) const;
35  bool operator==(const Swath& s) const;
36  bool operator>=(const Swath& s) const;
37  bool operator<=(const Swath& s) const;
38  bool operator>(const Swath& s) const;
39  bool operator<(const Swath& s) const;
40 
41  public:
42  void setId(int id);
43  int getId() const;
44 
45  void setPath(const LineString& path);
46  LineString getPath() const;
47 
48  void setWidth(double width);
49  double getWidth() const;
50 
51  bool getCreationDir() const;
52  void setCreationDir(bool creation_dir);
53 
54  SwathType getType() const;
55  void setType(SwathType type);
56 
57  public:
58  double length() const;
59 
60  double area() const;
61  double area(const Cells& polys) const;
62 
63  void reverse();
64 
65  double getInAngle() const;
66 
67  double getOutAngle() const;
68 
69  Point startPoint() const;
70 
71  Point endPoint() const;
72 
73  Cells areaCovered() const;
74  Cells areaCovered(const Cells& polys) const;
75  Swath clone() const;
76 
77  size_t numPoints() const;
78 
79  Point getPoint(int i);
80  const Point getPoint(int i) const;
81 
82 
84  bool hasSameDir(const Swath& s) const;
85 
88  void targetSameDirAs(const Swath& s);
89 
92  void targetOppositeDirAs(const Swath& s);
93 
95  void moveTo(const Point& ref_pt);
96 
97  private:
98  int id_ {0}; // Id of the swath
100  double width_ {0.0};
101  bool creation_dir_ {true};
103 };
104 
105 
106 } // namespace f2c::types
107 
108 #endif // FIELDS2COVER_TYPES_SWATH_H_
f2c::types::Swath::hasSameDir
bool hasSameDir(const Swath &s) const
Check if the difference between swaths angles is less than pi.
Definition: Swath.cpp:123
f2c::types::Swath::getId
int getId() const
Definition: Swath.cpp:151
f2c::types::Swath::clone
Swath clone() const
Definition: Swath.cpp:117
f2c::types::Swath::numPoints
size_t numPoints() const
Definition: Swath.cpp:139
f2c::types::Swath::creation_dir_
bool creation_dir_
Definition: Swath.h:101
f2c::types::Swath::operator=
virtual Swath & operator=(Swath &&)
f2c::types
Types used by fields2cover library.
Definition: Cell.h:20
f2c::types::Swath::path_
LineString path_
Definition: Swath.h:99
2_objective_functions.path
path
Definition: 2_objective_functions.py:88
f2c::types::Swath::getInAngle
double getInAngle() const
Definition: Swath.cpp:77
f2c::types::Swath::operator<
bool operator<(const Swath &s) const
Definition: Swath.cpp:42
f2c::types::Swath::getWidth
double getWidth() const
Definition: Swath.cpp:167
f2c::types::Swath::~Swath
virtual ~Swath()
f2c::types::Swath
Definition: Swath.h:23
f2c::types::Swath::setPath
void setPath(const LineString &path)
Definition: Swath.cpp:163
f2c::types::Swath::targetOppositeDirAs
void targetOppositeDirAs(const Swath &s)
Definition: Swath.cpp:133
f2c::types::Swath::areaCovered
Cells areaCovered() const
Definition: Swath.cpp:106
f2c::types::Swath::reverse
void reverse()
Definition: Swath.cpp:72
f2c::types::Swath::setType
void setType(SwathType type)
Definition: Swath.cpp:190
f2c::types::Swath::getPath
LineString getPath() const
Definition: Swath.cpp:159
f2c::types::Swath::id_
int id_
Definition: Swath.h:98
f2c::types::Swath::setId
void setId(int id)
Definition: Swath.cpp:155
f2c::types::Swath::operator>
bool operator>(const Swath &s) const
Definition: Swath.cpp:46
f2c::types::Swath::moveTo
void moveTo(const Point &ref_pt)
Moves swath data by a reference point.
Definition: Swath.cpp:194
f2c::types::Swath::length
double length() const
Definition: Swath.cpp:60
f2c::types::Swath::Swath
Swath()
f2c::types::Swath::targetSameDirAs
void targetSameDirAs(const Swath &s)
Definition: Swath.cpp:127
f2c::types::SwathType::MAINLAND
@ MAINLAND
LineString.h
f2c::types::Swath::endPoint
Point endPoint() const
Definition: Swath.cpp:99
2_objective_functions.width
float width
Definition: 2_objective_functions.py:29
f2c::types::Swath::operator==
bool operator==(const Swath &s) const
Definition: Swath.cpp:38
f2c::types::LineString
Definition: LineString.h:19
f2c::types::Swath::setWidth
void setWidth(double width)
Definition: Swath.cpp:171
f2c::types::Swath::getPoint
Point getPoint(int i)
Definition: Swath.cpp:143
f2c::types::SwathType::HEADLAND
@ HEADLAND
f2c::types::Swath::startPoint
Point startPoint() const
Definition: Swath.cpp:92
f2c::types::Cells
Definition: Cells.h:21
f2c::types::Swath::getCreationDir
bool getCreationDir() const
Definition: Swath.cpp:178
f2c::types::Point
Definition: Point.h:21
f2c::types::Swath::operator!=
bool operator!=(const Swath &s) const
Definition: Swath.cpp:28
f2c::types::Swath::width_
double width_
Definition: Swath.h:100
f2c::types::Swath::getType
SwathType getType() const
Definition: Swath.cpp:186
Cells.h
f2c::types::Swath::setCreationDir
void setCreationDir(bool creation_dir)
Definition: Swath.cpp:182
f2c::types::SwathType
SwathType
Definition: Swath.h:21
f2c::types::Swath::area
double area() const
Definition: Swath.cpp:64
f2c::types::Swath::operator>=
bool operator>=(const Swath &s) const
Definition: Swath.cpp:50
f2c::types::Swath::getOutAngle
double getOutAngle() const
Definition: Swath.cpp:84
f2c::types::Swath::operator<=
bool operator<=(const Swath &s) const
Definition: Swath.cpp:55
f2c::types::Swath::type_
SwathType type_
Definition: Swath.h:102


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