Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
IPolygon.hpp
Go to the documentation of this file.
1#pragma once
2#include "GeometryBase.hpp"
3#include "IRing.hpp"
4
5namespace fishnet::geometry::__impl{
6template<typename T>
7class PolygonStub{
8public:
9 using numeric_type = T;
10 constexpr static GeometryType type = GeometryType::POLYGON;
11 PolygonStub(RingStub<T> boundary, std::vector<RingStub<T>> holes){}
12 bool operator==(const PolygonStub<T> & other) const noexcept{
13 return true;
14 }
15 RingStub<T> getBoundary() const{
16 return RingStub<T>({}, {});
17 }
18 std::vector<RingStub<T>> getHoles() const{
19 return {};
20 }
21 bool isSimple() const{
22 return true;
23 }
24 double area() const{
25 return 0.0;
26 }
27 PointStub<double> centroid() const{
28 return PointStub<double>(0,0);
29 }
30 EnvelopeStub<T> aaBB() const{
31 return EnvelopeStub<T>(0,0,0,0);
32 }
33 bool isInside(PointStub<T> point) const{
34 return true;
35 }
36 bool isOnBoundary(PointStub<T> point) const{
37 return true;
38 }
39 bool isOutside(PointStub<T> point) const{
40 return true;
41 }
42 bool containsInHole(PointStub<T> point) const{
43 return true;
44 }
45 bool containsInHole(PolygonStub<T> polygon) const{
46 return true;
47 }
48 bool contains(PointStub<T> point) const{
49 return true;
50 }
51 bool contains(SegmentStub<T> segment) const{
52 return true;
53 }
54 bool contains(RingStub<T> ring) const{
55 return true;
56 }
57 bool contains(PolygonStub<T> polygon) const{
58 return true;
59 }
60 bool intersects(SegmentStub<T> segment) const{
61 return true;
62 }
63 bool intersects(LineStub<T> line) const{
64 return true;
65 }
66 std::vector<PointStub<double>> intersections(SegmentStub<T> segment) const{
67 return {};
68 }
69 std::vector<PointStub<double>> intersections(LineStub<T> line) const{
70 return {};
71 }
72 bool crosses(PolygonStub<T> polygon) const{
73 return true;
74 }
75 bool touches(PolygonStub<T> polygon) const{
76 return true;
77 }
78 double distance(PolygonStub<T> polygon) const{
79 return 0.0;
80 }
81 size_t hash() const noexcept {
82 return 0;
83 }
84 std::string toString() const{
85 return {};
86 }
87};
88} // namespace fishnet::geometry::__impl
89
90namespace fishnet::geometry{
91
97template<typename P>
98concept IPolygon = GeometryBase<P> && requires(
99 const std::remove_cvref_t<P> & polygon,
100 const __impl::PolygonStub<typename std::remove_cvref_t<P>::numeric_type> & otherPolygon,
101 const __impl::RingStub<typename std::remove_cvref_t<P>::numeric_type> & ring,
102 const __impl::PointStub<typename std::remove_cvref_t<P>::numeric_type> & point,
103 const __impl::SegmentStub<typename std::remove_cvref_t<P>::numeric_type> & segment,
104 const __impl::LineStub<typename std::remove_cvref_t<P>::numeric_type> & line
105){
106 {polygon.getBoundary()} -> IRing;
107 {polygon.getHoles()} -> RingRange;
108 {polygon.isSimple()} -> std::same_as<bool>;
109 {polygon.area()} -> std::convertible_to<double>;
110 {polygon.centroid()} -> IPoint;
111 {polygon.aaBB()} -> IEnvelope;
112 {polygon.isInside(point)} -> std::same_as<bool>;
113 {polygon.isOnBoundary(point)} -> std::same_as<bool>;
114 {polygon.isOutside(point)} -> std::same_as<bool>;
115 {polygon.containsInHole(point)} -> std::same_as<bool>;
116 {polygon.containsInHole(otherPolygon)} -> std::same_as<bool>;
117 {polygon.contains(point)} -> std::same_as<bool>;
118 {polygon.contains(segment)} -> std::same_as<bool>;
119 {polygon.contains(ring)} -> std::same_as<bool>;
120 {polygon.contains(otherPolygon)} -> std::same_as<bool>;
121 {polygon.intersects(segment)} -> std::same_as<bool>;
122 {polygon.intersects(line)} -> std::same_as<bool>;
123 {polygon.intersections(segment)} -> PointRange;
124 {polygon.intersections(line)} -> PointRange;
125 {polygon.crosses(otherPolygon)} -> std::same_as<bool>;
126 {polygon.touches(otherPolygon)} -> std::same_as<bool>;
127 {polygon.distance(otherPolygon)} -> std::convertible_to<double>;
128};
129
132
133template<typename R>
134concept PolygonRange = std::ranges::forward_range<R> && IPolygon<std::ranges::range_value_t<R>>;
136} // namespace fishnet::geometry
IPolygon implementation backed by an OGRPolygon.
Definition OGRPolygonAdapter.hpp:22
Definition GeometryBase.hpp:11
Definition IRing.hpp:128
Interface for a point.
Definition IPoint.hpp:92
Interface for a polygon A polygon is a two-dimensional shape defined by a boundary and zero or more h...
Definition IPolygon.hpp:98
Interface for a ring A ring is a closed loop of segments, forming a boundary of a shape.
Definition IRing.hpp:143
Definition IPoint.hpp:138
Definition IPolygon.hpp:134
Definition IRing.hpp:176
Definition BoundingBoxWrapper.hpp:5