Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
ILine.hpp
Go to the documentation of this file.
1#pragma once
2#include "GeometryBase.hpp"
3#include "IPoint.hpp"
4#include <fishnet/Option.hpp>
5
6namespace fishnet::geometry::__impl{
7template<typename T>
8class LineStub{
9public:
10 using numeric_type = T;
11 constexpr static GeometryType type = GeometryType::LINE;
12 PointStub<T> p() const{
13 return PointStub<T>(0,0);
14 }
15 PointStub<T> q() const{
16 return PointStub<T>(1,1);
17 }
18 LineStub(PointStub<T> p, PointStub<T> q){}
19 LineStub(T slope, T yIntercept){}
20 bool operator==(const LineStub & other) const noexcept{
21 return true;
22 }
23 PointStub<T> direction() const{
24 return PointStub<T>(1,1);
25 }
26 bool isVertical()const{
27 return false;
28 }
29 bool isHorizontal()const{
30 return false;
31 }
32 double slope()const{
33 return 1.0;
34 }
35 fishnet::Option<double> yIntercept()const{
36 return fishnet::Option<double>(0.0);
37 }
38 bool contains(IPoint auto point)const{
39 return true;
40 }
41 bool isLeft(IPoint auto point)const{
42 return true;
43 }
44 bool isRight(IPoint auto point)const{
45 return true;
46 }
47 bool isParallel (LineStub line)const{
48 return true;
49 }
50 bool intersects(LineStub line)const{
51 return true;
52 }
53 fishnet::Option<PointStub<double>> intersection(LineStub<T> line)const{
54 return fishnet::Option<PointStub<double>>(PointStub<double>(0,0));
55 }
56 LineStub toLine()const{
57 return *this;
58 }
59 size_t hash() const noexcept {
60 return 0;
61 }
62 std::string toString() const {
63 return {};
64 }
65};
66} // namespace fishnet::geometry::__impl
67
68namespace fishnet::geometry{
69
75template<typename L>
76concept ILine = GeometryBase<L> && requires (
77 const std::remove_cvref_t<L> & line,
78 const __impl::LineStub<typename std::remove_cvref_t<L>::numeric_type> & otherLine,
79 const __impl::PointStub<typename std::remove_cvref_t<L>::numeric_type> & point,
80 typename std::remove_cvref_t<L>::numeric_type number
81){
82 {line.p()} -> IPoint;
83 {line.q()} -> IPoint;
84 {std::remove_cvref_t<L>(number, number)} -> std::same_as<std::remove_cvref_t<L>>; // slope and y intercept constructor
85 {line.direction()} -> IPoint;
86 {line.isVertical()} -> std::same_as<bool>;
87 {line.isHorizontal()} -> std::same_as<bool>;
88 {line.slope()} -> std::convertible_to<double>;
89 {line.yIntercept()} -> std::same_as<fishnet::Option<double>>;
90 {line.contains(point)}-> std::same_as<bool>;
91 {line.isLeft(point)} -> std::same_as<bool>;
92 {line.isRight(point)} -> std::same_as<bool>;
93 {line.isParallel(otherLine)} -> std::same_as<bool>;
94 {line.intersects(otherLine)} ->std::same_as<bool>;
95 {line.intersection(otherLine)} -> IPointOptional;
96 {line.toLine()} -> std::same_as<std::remove_cvref_t<L>>;
97};
98static_assert(ILine<__impl::LineStub<double>>);
99static_assert(ILine<__impl::LineStub<int>>);
100} // namespace fishnet::geometry
101
Definition Option.hpp:13
IPolygon implementation backed by an OGRPolygon.
Definition OGRPolygonAdapter.hpp:22
Definition GeometryBase.hpp:11
Interface for a line A line is defined through two points p and q, defining a direction vector.
Definition ILine.hpp:76
Definition IPoint.hpp:135
Interface for a point.
Definition IPoint.hpp:92
Definition BoundingBoxWrapper.hpp:5