Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
IRing.hpp
Go to the documentation of this file.
1#pragma once
3#include "GeometryBase.hpp"
4#include "ISegment.hpp"
5
6namespace fishnet::geometry::__impl{
7template<typename T>
8class RingStub;
9
10template<typename T>
11class EnvelopeStub{
12public:
13 using numeric_type = T;
14 constexpr static GeometryType type = GeometryType::RING;
15 EnvelopeStub(T left, T top, T right, T bottom){}
16 bool contains(const PointStub<T> & point) const{
17 return true;
18 }
19 bool overlap(const EnvelopeStub<T> & other) const{
20 return true;
21 }
22 T left() const{
23 return 0;
24 }
25 T right() const{
26 return 0;
27 }
28 T top() const{
29 return 0;
30 }
31 T bottom() const{
32 return 0;
33 }
34 bool operator==(const EnvelopeStub<T> & other) const noexcept{
35 return true;
36 }
37 size_t hash() const noexcept {
38 return 0;
39 }
40 std::string toString() const{
41 return {};
42 }
43};
44
45
46template<typename T>
47class RingStub{
48public:
49 using numeric_type = T;
50 constexpr static GeometryType type = GeometryType::RING;
51 RingStub(std::vector<SegmentStub<T>> segments){}
52 RingStub(std::vector<PointStub<T>> points){}
53 bool operator==(const RingStub<T> & other) const noexcept{
54 return true;
55 }
56 std::vector<SegmentStub<T>> getSegments() const{
57 return {};
58 }
59 std::vector<PointStub<T>> getPoints() const{
60 return {};
61 }
62 RingStub<T> getBoundary() const{
63 return *this;
64 }
65 std::vector<RingStub<T>> getHoles() const{
66 return {};
67 }
68 double area() const{
69 return 0.0;
70 }
71 PointStub<double> centroid() const{
72 return PointStub<double>(0,0);
73 }
74 EnvelopeStub<T> aaBB() const{
75 return EnvelopeStub<T>(0, 0, 0, 0);
76 }
77 bool isInside(PointStub<T> point) const{
78 return true;
79 }
80 bool isOnBoundary(PointStub<T> point) const{
81 return true;
82 }
83 bool isOutside(PointStub<T> point) const{
84 return true;
85 }
86 bool contains(PointStub<T> point) const{
87 return true;
88 }
89 bool contains(SegmentStub<T> segment) const{
90 return true;
91 }
92 bool contains(RingStub<T> ring) const{
93 return true;
94 }
95 bool intersects(SegmentStub<T> segment) const{
96 return true;
97 }
98 bool intersects(LineStub<T> line) const{
99 return true;
100 }
101 std::vector<PointStub<double>> intersections(SegmentStub<T> segment) const{
102 return {};
103 }
104 std::vector<PointStub<double>> intersections(LineStub<T> line) const{
105 return {};
106 }
107 bool crosses(RingStub<T> ring) const{
108 return true;
109 }
110 bool touches(RingStub<T> ring) const{
111 return true;
112 }
113 double distance(RingStub<T> ring) const{
114 return 0.0;
115 }
116 size_t hash() const noexcept {
117 return 0;
118 }
119 std::string toString() const{
120 return {};
121 }
122};
123} // namespace fishnet::geometry::__impl
124
125namespace fishnet::geometry{
126
127template<typename E>
128concept IEnvelope = GeometryBase<E> && requires(const std::remove_cvref_t<E> & env, const __impl::PointStub<typename std::remove_cvref_t<E>::numeric_type> & point){
129 {env.contains(point)} -> std::same_as<bool>;
130 {env.overlap(env)} -> std::same_as<bool>;
131 {env.left()} -> std::convertible_to<typename std::remove_cvref_t<E>::numeric_type>;
132 {env.right()} -> std::convertible_to<typename std::remove_cvref_t<E>::numeric_type>;
133 {env.top()} -> std::convertible_to<typename std::remove_cvref_t<E>::numeric_type>;
134 {env.bottom()} -> std::convertible_to<typename std::remove_cvref_t<E>::numeric_type>;
135};
136
142template<typename R>
143concept IRing = GeometryBase<R> && requires(
144 const std::remove_cvref_t<R> & ring,
145 const __impl::RingStub<typename std::remove_cvref_t<R>::numeric_type> & otherRing,
146 const __impl::SegmentStub<typename std::remove_cvref_t<R>::numeric_type> & segment,
147 const __impl::LineStub<typename std::remove_cvref_t<R>::numeric_type> & line,
148 const __impl::PointStub<typename std::remove_cvref_t<R>::numeric_type> & point
149){
150 {ring.getSegments()} -> SegmentRange;
151 {ring.getPoints()} -> PointRange;
152 {ring.getBoundary()} -> std::convertible_to<std::remove_cvref_t<R>>;
153 {ring.getHoles()} -> std::ranges::range; // should always be empty
154 {ring.area()} -> std::convertible_to<double>;
155 {ring.centroid()} -> IPoint;
156 {ring.aaBB()} -> IEnvelope;
157 {ring.isInside(point)} -> std::same_as<bool>;
158 {ring.isOnBoundary(point)} -> std::same_as<bool>;
159 {ring.isOutside(point)} -> std::same_as<bool>;
160 {ring.contains(point)} -> std::same_as<bool>;
161 {ring.contains(segment)} -> std::same_as<bool>;
162 {ring.contains(otherRing)} -> std::same_as<bool>;
163 {ring.intersects(segment)} -> std::same_as<bool>;
164 {ring.intersects(line)} -> std::same_as<bool>;
165 {ring.intersections(segment)} -> PointRange;
166 {ring.intersections(line)} -> PointRange;
167 {ring.crosses(otherRing)} -> std::same_as<bool>;
168 {ring.touches(otherRing)} -> std::same_as<bool>;
169 {ring.distance(otherRing)} -> std::convertible_to<double>;
170};
171
172static_assert(IRing<__impl::RingStub<double>>);
173static_assert(IRing<__impl::RingStub<int>>);
174
175template<typename R>
176concept RingRange = std::ranges::range<R> && IRing<std::ranges::range_value_t<R>>;
178} // 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 ring A ring is a closed loop of segments, forming a boundary of a shape.
Definition IRing.hpp:143
Definition IPoint.hpp:138
Definition IRing.hpp:176
Definition ISegment.hpp:141
Definition BoundingBoxWrapper.hpp:5