cesium-native 0.50.0
Loading...
Searching...
No Matches
GlobeRectangle.h
1#pragma once
2
3#include <CesiumGeometry/Rectangle.h>
4#include <CesiumGeospatial/Cartographic.h>
5#include <CesiumGeospatial/Library.h>
6#include <CesiumUtility/Math.h>
7
8#include <optional>
9
10namespace CesiumGeospatial {
11
23class CESIUMGEOSPATIAL_API GlobeRectangle final {
24public:
34 static const GlobeRectangle EMPTY;
35
45 static const GlobeRectangle MAXIMUM;
46
57 constexpr GlobeRectangle(
58 double west,
59 double south,
60 double east,
61 double north) noexcept
62 : _west(west), _south(south), _east(east), _north(north) {}
63
74 static constexpr GlobeRectangle
76 return GlobeRectangle(
77 rectangle.minimumX,
78 rectangle.minimumY,
79 rectangle.maximumX,
80 rectangle.maximumY);
81 }
82
99 static constexpr GlobeRectangle fromDegrees(
100 double westDegrees,
101 double southDegrees,
102 double eastDegrees,
103 double northDegrees) noexcept {
104 return GlobeRectangle(
109 }
110
114 constexpr double getWest() const noexcept { return this->_west; }
115
119 void setWest(double value) noexcept { this->_west = value; }
120
124 constexpr double getSouth() const noexcept { return this->_south; }
125
129 void setSouth(double value) noexcept { this->_south = value; }
130
134 constexpr double getEast() const noexcept { return this->_east; }
135
139 void setEast(double value) noexcept { this->_east = value; }
140
144 constexpr double getNorth() const noexcept { return this->_north; }
145
149 void setNorth(double value) noexcept { this->_north = value; }
150
154 constexpr Cartographic getSouthwest() const noexcept {
155 return Cartographic(this->_west, this->_south);
156 }
157
161 constexpr Cartographic getSoutheast() const noexcept {
162 return Cartographic(this->_east, this->_south);
163 }
164
168 constexpr Cartographic getNorthwest() const noexcept {
169 return Cartographic(this->_west, this->_north);
170 }
171
175 constexpr Cartographic getNortheast() const noexcept {
176 return Cartographic(this->_east, this->_north);
177 }
178
182 constexpr CesiumGeometry::Rectangle toSimpleRectangle() const noexcept {
184 this->getWest(),
185 this->getSouth(),
186 this->getEast(),
187 this->getNorth());
188 }
189
195 constexpr double computeWidth() const noexcept {
196 double east = this->_east;
197 const double west = this->_west;
198 if (east < west) {
200 }
201 return east - west;
202 }
203
209 constexpr double computeHeight() const noexcept {
210 return this->_north - this->_south;
211 }
212
216 Cartographic computeCenter() const noexcept;
217
227 bool contains(const Cartographic& cartographic) const noexcept;
228
234 bool isEmpty() const noexcept;
235
251 std::optional<GlobeRectangle>
252 computeIntersection(const GlobeRectangle& other) const noexcept;
253
260 GlobeRectangle computeUnion(const GlobeRectangle& other) const noexcept;
261
272 std::pair<GlobeRectangle, std::optional<GlobeRectangle>>
273 splitAtAntiMeridian() const noexcept;
274
282 static bool
283 equals(const GlobeRectangle& left, const GlobeRectangle& right) noexcept;
284
294 static bool equalsEpsilon(
295 const GlobeRectangle& left,
296 const GlobeRectangle& right,
297 double relativeEpsilon) noexcept;
298
299private:
300 double _west;
301 double _south;
302 double _east;
303 double _north;
304};
305
306} // namespace CesiumGeospatial
A position defined by longitude, latitude, and height.
A two-dimensional, rectangular region on a globe, specified using longitude and latitude coordinates....
constexpr double getWest() const noexcept
Returns the westernmost longitude, in radians.
constexpr double computeWidth() const noexcept
Computes the width of this rectangle.
constexpr double getNorth() const noexcept
Returns the northernmost latitude, in radians.
Cartographic computeCenter() const noexcept
Computes the Cartographic center position of this rectangle.
static const GlobeRectangle MAXIMUM
The maximum rectangle.
void setNorth(double value) noexcept
Sets the northernmost latitude, in radians.
constexpr GlobeRectangle(double west, double south, double east, double north) noexcept
Constructs a new instance.
static bool equals(const GlobeRectangle &left, const GlobeRectangle &right) noexcept
Checks whether two globe rectangles are exactly equal.
constexpr Cartographic getSouthwest() const noexcept
Returns the Cartographic position of the south-west corner.
bool isEmpty() const noexcept
Determines if this rectangle is empty.
constexpr Cartographic getNortheast() const noexcept
Returns the Cartographic position of the north-east corner.
static constexpr GlobeRectangle fromDegrees(double westDegrees, double southDegrees, double eastDegrees, double northDegrees) noexcept
static bool equalsEpsilon(const GlobeRectangle &left, const GlobeRectangle &right, double relativeEpsilon) noexcept
Checks whether two globe rectangles are equal up to a given relative epsilon.
constexpr double getEast() const noexcept
Returns the easternmost longitude, in radians.
void setWest(double value) noexcept
Sets the westernmost longitude, in radians.
bool contains(const Cartographic &cartographic) const noexcept
Returns true if this rectangle contains the given point.
std::optional< GlobeRectangle > computeIntersection(const GlobeRectangle &other) const noexcept
Computes the intersection of two rectangles.
constexpr Cartographic getSoutheast() const noexcept
Returns the Cartographic position of the south-east corner.
constexpr CesiumGeometry::Rectangle toSimpleRectangle() const noexcept
Returns this rectangle as a CesiumGeometry::Rectangle.
static constexpr GlobeRectangle fromRectangleRadians(const CesiumGeometry::Rectangle &rectangle) noexcept
Constructs a new GlobeRectangle from the provided Rectangle.
void setSouth(double value) noexcept
Sets the southernmost latitude, in radians.
void setEast(double value) noexcept
Sets the easternmost longitude, in radians.
constexpr double computeHeight() const noexcept
Computes the height of this rectangle.
GlobeRectangle computeUnion(const GlobeRectangle &other) const noexcept
Computes the union of this globe rectangle with another.
static const GlobeRectangle EMPTY
An empty rectangle.
constexpr Cartographic getNorthwest() const noexcept
Returns the Cartographic position of the north-west corner.
constexpr double getSouth() const noexcept
Returns the southernmost latitude, in radians.
std::pair< GlobeRectangle, std::optional< GlobeRectangle > > splitAtAntiMeridian() const noexcept
Splits this rectangle at the anti-meridian (180 degrees longitude), if necessary.
static constexpr double degreesToRadians(double angleDegrees) noexcept
Converts degrees to radians.
Definition Math.h:367
static constexpr double TwoPi
Two times pi.
Definition Math.h:86
Classes for geospatial computations in Cesium.
STL namespace.
A 2D rectangle.
Definition Rectangle.h:14