14template<fishnet::math::Number T>
22 void init()
noexcept {
23 for(
const auto p : this->
getPoints() | std::views::take(1)){
46 Rectangle(T
left, T
top, T
right, T
bottom):
Ring<T>({{
left,
top},{
right,
top},{
right,
bottom},{
left,
bottom}}),_left(
left),_top(
top),_right(
right),_bottom(
bottom){}
53 :
Rectangle(
std::min(corner.x, oppositeCorner.x),
std::max(corner.y, oppositeCorner.y),
54 std::max(corner.x, oppositeCorner.x),
std::min(corner.y, oppositeCorner.y)) {}
64 T
top() const noexcept {
78 std::cerr <<
"Scale factor must be greater than 0!" << std::endl;
81 auto xDiff = (_right - _left) * (factor-1);
82 auto yDiff = (_top - _bottom) * (factor-1);
83 auto top = _top + yDiff;
84 auto bottom = _bottom - yDiff;
85 auto left = _left - xDiff;
86 auto right = _right + xDiff;
90 template<fishnet::math::Number U>
92 if(this->
right() < other.left() || this->left() > other.right())
94 if(this->
top() < other.bottom() || this->bottom() > other.top())
119template<std::ranges::range R>
122 using number =
typename std::ranges::range_value_t<R>::numeric_type;
123 number left = std::numeric_limits<number>::max();
124 number right = std::numeric_limits<number>::lowest();
125 number top = std::numeric_limits<number>::lowest();
126 number bottom = std::numeric_limits<number>::max();
128 throw std::runtime_error(
"Range of polygons is empty, cannot compute bounding box");
130 for(
const auto & polygon: polygons){
132 if(aaBB.left() < left)
134 if(aaBB.right() > right)
135 right = aaBB.right();
138 if(aaBB.bottom() < bottom)
139 bottom = aaBB.bottom();
143static_assert(IEnvelope<Rectangle<double>>);
144static_assert(Shape<Ring<double>>);
145static_assert(IRing<Ring<double>>);
146static_assert(IRing<Rectangle<double>>);
Implementation of a rectangle Stores top,right,bottom and left point of the rectangle.
Definition Rectangle.hpp:15
Rectangle< T > scale(T factor) const noexcept
Definition Rectangle.hpp:76
T left() const noexcept
Definition Rectangle.hpp:56
T right() const noexcept
Definition Rectangle.hpp:60
Rectangle(T left, T top, T right, T bottom)
Definition Rectangle.hpp:46
Rectangle(Shape auto const &ring)
Definition Rectangle.hpp:42
const Rectangle< T > & aaBB() const noexcept
Definition Rectangle.hpp:72
bool overlap(const Rectangle< U > &other) const noexcept
Definition Rectangle.hpp:91
Rectangle(Vec2D< T > const &corner, Vec2D< T > const &oppositeCorner)
Construct the rectangle spanned by two opposite corners.
Definition Rectangle.hpp:52
T bottom() const noexcept
Definition Rectangle.hpp:68
T top() const noexcept
Definition Rectangle.hpp:64
Implementation of a ring.
Definition Ring.hpp:31
constexpr util::view_of< Vec2D< T > > auto getPoints() const noexcept
Definition Ring.hpp:141
Implementation of a two-dimensional vector.
Definition Vec2D.hpp:16
A geometry enclosing an area: a ring, a polygon or a multi-polygon.
Definition IGeometry.hpp:23
Definition BoundingBoxWrapper.hpp:5
static Rectangle< typename std::ranges::range_value_t< R >::numeric_type > minimalBoundingBox(const R &polygons)
Helper function to get the common bounding box for a range of polygons.
Definition Rectangle.hpp:120
constexpr bool isEmpty(std::ranges::range auto &&range) noexcept
Definition CollectionConcepts.hpp:59