Cells.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_CELLS_H_
9 #define FIELDS2COVER_TYPES_CELLS_H_
10 
11 #include <gdal/ogr_geometry.h>
12 #include <vector>
18 
19 namespace f2c::types {
20 
21 struct Cells : public Geometries<Cells, OGRMultiPolygon, wkbMultiPolygon,
22  Cell> {
23  public:
25  Cells();
26  explicit Cells(const OGRGeometry* geom);
27  explicit Cells(const Cell& c);
28  ~Cells() = default;
29 
30  void getGeometry(size_t i, Cell& cell);
31  void getGeometry(size_t i, Cell& cell) const;
32  Cell getGeometry(size_t i);
33  const Cell getGeometry(size_t i) const;
34  void setGeometry(size_t i, const Cell& cell);
35 
36  const Cell getCell(size_t i) const;
37  const LinearRing getCellBorder(size_t i) const;
38  const LinearRing getInteriorRing(size_t i_cell, size_t i_ring) const;
39 
40 
41  void operator*=(double b);
42 
43  void addGeometry(const Cell& c);
44  void addRing(size_t i, const LinearRing& ring);
45 
46  size_t size() const;
47 
48  bool isConvex() const;
49 
50  Cell convexHull() const;
51 
52  static Cells intersection(const Cell& cell, const Cell& c);
53  Cells intersection(const Cell& c) const;
54  Cells intersection(const Cells& c) const;
55 
56  Cells difference(const Cell& c) const;
57  Cells difference(const Cells& c) const;
58 
59  Cells unionOp(const Cell& c) const;
60  Cells unionOp(const Cells& c) const;
61 
62  Cells unionCascaded() const;
63 
64  Cells splitByLine(const LineString& line) const;
65 
66  Cells splitByLine(const MultiLineString& lines) const;
67 
68  LineString createSemiLongLine(const Point& point, double angle) const;
69 
70  LineString createStraightLongLine(const Point& point, double angle) const;
71 
72  MultiLineString getLinesInside(const LineString& line) const;
73 
75 
76  Cells getCellsInside(const Cells& cell) const;
77 
78  bool isPointInBorder(const Point& p) const;
79 
80  bool isPointIn(const Point& p) const;
81 
82  const Cell getCellWherePoint(const Point& p) const;
83 
85  const f2c::types::Point& p, double ang) const;
86 
87  template <class T, OGRwkbGeometryType R>
88  static Cells buffer(const Geometry<T, R>& geom, double width,
89  int side = 0);
90 
91  Cells buffer(double width) const;
92 
93  Point closestPointOnBorderTo(const Point& p) const;
94 };
95 
96 
97 
98 template <class T, OGRwkbGeometryType R>
99 Cells Cells::buffer(const Geometry<T, R>& geom, double width, int side) {
100  OGRGeometry* buffer = geom.OGRBuffer(width, side);
101  Cells cells {buffer};
102  OGRGeometryFactory::destroyGeometry(buffer);
103  return cells;
104 }
105 
106 
107 } // namespace f2c::types
108 
109 #endif // FIELDS2COVER_TYPES_CELLS_H_
f2c::types::Cells::unionOp
Cells unionOp(const Cell &c) const
Definition: Cells.cpp:172
Cell.h
1_basic_types.cells
cells
Definition: 1_basic_types.py:93
Point.h
f2c::types
Types used by fields2cover library.
Definition: Cell.h:20
f2c::types::Cells::~Cells
~Cells()=default
f2c::types::Cells::closestPointOnBorderTo
Point closestPointOnBorderTo(const Point &p) const
Definition: Cells.cpp:246
f2c::types::Geometry
Definition: Geometry.h:26
f2c::types::Cells::convexHull
Cell convexHull() const
Definition: Cells.cpp:144
f2c::types::Cells::Cells
Cells()
Definition: Cells.cpp:12
f2c::types::Cells::intersection
static Cells intersection(const Cell &cell, const Cell &c)
Definition: Cells.cpp:148
f2c::types::Cells::addGeometry
void addGeometry(const Cell &c)
Definition: Cells.cpp:126
1_basic_types.cell
cell
Definition: 1_basic_types.py:88
Geometry.h
f2c::types::Cells::getCellBorder
const LinearRing getCellBorder(size_t i) const
Definition: Cells.cpp:116
f2c::types::Cells::isConvex
bool isConvex() const
Definition: Cells.cpp:139
f2c::types::Cells::createSemiLongLine
LineString createSemiLongLine(const Point &point, double angle) const
Definition: Cells.cpp:196
f2c::types::Cells::size
size_t size() const
Definition: Cells.cpp:135
f2c::types::MultiLineString
Definition: MultiLineString.h:18
f2c::types::LinearRing
Definition: LinearRing.h:18
f2c::types::Geometry::OGRBuffer
OGRGeometry * OGRBuffer(double dfDist, int side=0) const
Definition: Geometry_impl.hpp:291
f2c::types::Cell
Definition: Cell.h:32
f2c::types::Cells::splitByLine
Cells splitByLine(const LineString &line) const
Definition: Cells.cpp:180
LineString.h
1_basic_types.ring
ring
Definition: 1_basic_types.py:68
2_objective_functions.width
float width
Definition: 2_objective_functions.py:29
f2c::types::Cells::unionCascaded
Cells unionCascaded() const
Definition: Cells.cpp:176
f2c::types::Cells::difference
Cells difference(const Cell &c) const
Definition: Cells.cpp:164
f2c::types::LineString
Definition: LineString.h:19
Geometries.h
f2c::types::Cells
Definition: Cells.h:21
f2c::types::Cells::getCellsInside
Cells getCellsInside(const Cells &cell) const
Definition: Cells.cpp:216
f2c::types::Point
Definition: Point.h:21
f2c::types::Cells::getCell
const Cell getCell(size_t i) const
Definition: Cells.cpp:112
f2c::types::Cells::getLinesInside
MultiLineString getLinesInside(const LineString &line) const
Definition: Cells.cpp:208
f2c::types::Cells::createLineUntilBorder
LineString createLineUntilBorder(const f2c::types::Point &p, double ang) const
Definition: Cells.cpp:237
f2c::types::Cells::operator*=
void operator*=(double b)
Definition: Cells.cpp:57
f2c::types::Cells::setGeometry
void setGeometry(size_t i, const Cell &cell)
Definition: Cells.cpp:95
f2c::types::Cells::getGeometry
void getGeometry(size_t i, Cell &cell)
Definition: Cells.cpp:63
f2c::types::Cells::isPointIn
bool isPointIn(const Point &p) const
Definition: Cells.cpp:224
f2c::types::Cells::addRing
void addRing(size_t i, const LinearRing &ring)
Definition: Cells.cpp:130
f2c::types::Cells::buffer
static Cells buffer(const Geometry< T, R > &geom, double width, int side=0)
Definition: Cells.h:99
f2c::types::Cells::getCellWherePoint
const Cell getCellWherePoint(const Point &p) const
Definition: Cells.cpp:228
f2c::types::Geometries
Definition: Geometries.h:21
1_basic_types.lines
lines
Definition: 1_basic_types.py:73
f2c::types::Cells::createStraightLongLine
LineString createStraightLongLine(const Point &point, double angle) const
Definition: Cells.cpp:201
f2c::types::Cells::isPointInBorder
bool isPointInBorder(const Point &p) const
Definition: Cells.cpp:220
f2c::types::Cells::getInteriorRing
const LinearRing getInteriorRing(size_t i_cell, size_t i_ring) const
Definition: Cells.cpp:121


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