Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
BoundingBoxWrapper.hpp
Go to the documentation of this file.
1#pragma once
6
12template<typename T, class ShapeProjection=std::identity> requires fishnet::geometry::Shape<std::invoke_result_t<ShapeProjection,T>>
14private:
15 const T element;
17 static inline ShapeProjection shapeProjection{};
18public:
19 using element_type = T;
20 using geometry_type = std::invoke_result_t<ShapeProjection,T>;
26 BoundingBoxWrapper(const T & element):element(element),boundingBox(shapeProjection(element)){}
27
34 BoundingBoxWrapper(const T & element, const Rectangle<fishnet::math::DEFAULT_NUMERIC> & boundingBox):element(element),boundingBox(boundingBox){}
35
37 return this->boundingBox;
38 }
39
40 auto getPolygon() const noexcept {
41 return shapeProjection(this->element);
42 }
43
44 const T & getElement() const noexcept {
45 return this->element;
46 }
47};
48
49template<typename T>
50concept IBoundingBoxWrapper = requires(T t){
51 {t.getBoundingBox()} -> std::convertible_to<Rectangle<fishnet::math::DEFAULT_NUMERIC>>;
52 {t.getPolygon()} -> fishnet::geometry::Shape;
53 typename T::element_type;
54 typename T::geometry_type;
55};
56
62template<IBoundingBoxWrapper BBWrapper>
64 bool operator()(const BBWrapper & lhs, const BBWrapper & rhs) const noexcept {
65 return lhs.getBoundingBox().top() > rhs.getBoundingBox().top();
66 }
67};
68
74template<IBoundingBoxWrapper BBWrapper>
76 bool operator()(const BBWrapper & lhs, const BBWrapper & rhs) const noexcept {
77 if(lhs.getBoundingBox().left() == rhs.getBoundingBox().left()){
78 return lhs.getBoundingBox().right() < rhs.getBoundingBox().right();
79 }
80 return lhs.getBoundingBox().left() < rhs.getBoundingBox().left();
81 }
82};
83}
Wrapper for Polygon objects, which stores a (custom) bounding box.
Definition BoundingBoxWrapper.hpp:13
BoundingBoxWrapper(const T &element)
Construct a new Bounding Box Polygon object, with default axis-aligned bounding box.
Definition BoundingBoxWrapper.hpp:26
const T & getElement() const noexcept
Definition BoundingBoxWrapper.hpp:44
T element_type
Definition BoundingBoxWrapper.hpp:19
BoundingBoxWrapper(const T &element, const Rectangle< fishnet::math::DEFAULT_NUMERIC > &boundingBox)
Construct a new Bounding Box Polygon object, with custom bounding box rectangle.
Definition BoundingBoxWrapper.hpp:34
const Rectangle< fishnet::math::DEFAULT_NUMERIC > & getBoundingBox() const noexcept
Definition BoundingBoxWrapper.hpp:36
std::invoke_result_t< ShapeProjection, T > geometry_type
Definition BoundingBoxWrapper.hpp:20
auto getPolygon() const noexcept
Definition BoundingBoxWrapper.hpp:40
Implementation of a rectangle Stores top,right,bottom and left point of the rectangle.
Definition Rectangle.hpp:15
Definition BoundingBoxWrapper.hpp:50
A geometry enclosing an area: a ring, a polygon or a multi-polygon.
Definition IGeometry.hpp:23
Definition BoundingBoxWrapper.hpp:5
Comparator for sorting BoundingBoxWrappers according to left-most position of the bounding box.
Definition BoundingBoxWrapper.hpp:75
bool operator()(const BBWrapper &lhs, const BBWrapper &rhs) const noexcept
Definition BoundingBoxWrapper.hpp:76
Comparator for sorting BoundingBoxWrappers according to top-most position of the bounding box.
Definition BoundingBoxWrapper.hpp:63
bool operator()(const BBWrapper &lhs, const BBWrapper &rhs) const noexcept
Definition BoundingBoxWrapper.hpp:64