cesium-native 0.44.2
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
80 static constexpr GlobeRectangle fromDegrees(
81 double westDegrees,
82 double southDegrees,
83 double eastDegrees,
84 double northDegrees) noexcept {
85 return GlobeRectangle(
90 }
91
95 constexpr double getWest() const noexcept { return this->_west; }
96
100 void setWest(double value) noexcept { this->_west = value; }
101
105 constexpr double getSouth() const noexcept { return this->_south; }
106
110 void setSouth(double value) noexcept { this->_south = value; }
111
115 constexpr double getEast() const noexcept { return this->_east; }
116
120 void setEast(double value) noexcept { this->_east = value; }
121
125 constexpr double getNorth() const noexcept { return this->_north; }
126
130 void setNorth(double value) noexcept { this->_north = value; }
131
135 constexpr Cartographic getSouthwest() const noexcept {
136 return Cartographic(this->_west, this->_south);
137 }
138
142 constexpr Cartographic getSoutheast() const noexcept {
143 return Cartographic(this->_east, this->_south);
144 }
145
149 constexpr Cartographic getNorthwest() const noexcept {
150 return Cartographic(this->_west, this->_north);
151 }
152
156 constexpr Cartographic getNortheast() const noexcept {
157 return Cartographic(this->_east, this->_north);
158 }
159
163 constexpr CesiumGeometry::Rectangle toSimpleRectangle() const noexcept {
165 this->getWest(),
166 this->getSouth(),
167 this->getEast(),
168 this->getNorth());
169 }
170
176 constexpr double computeWidth() const noexcept {
177 double east = this->_east;
178 const double west = this->_west;
179 if (east < west) {
181 }
182 return east - west;
183 }
184
190 constexpr double computeHeight() const noexcept {
191 return this->_north - this->_south;
192 }
193
197 Cartographic computeCenter() const noexcept;
198
208 bool contains(const Cartographic& cartographic) const noexcept;
209
215 bool isEmpty() const noexcept;
216
232 std::optional<GlobeRectangle>
233 computeIntersection(const GlobeRectangle& other) const noexcept;
234
241 GlobeRectangle computeUnion(const GlobeRectangle& other) const noexcept;
242
253 std::pair<GlobeRectangle, std::optional<GlobeRectangle>>
254 splitAtAntiMeridian() const noexcept;
255
263 static bool
264 equals(const GlobeRectangle& left, const GlobeRectangle& right) noexcept;
265
275 static bool equalsEpsilon(
276 const GlobeRectangle& left,
277 const GlobeRectangle& right,
278 double relativeEpsilon) noexcept;
279
280private:
281 double _west;
282 double _south;
283 double _east;
284 double _north;
285};
286
287} // 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.
constexpr Cartographic getSouthwest() const noexcept
Returns the Cartographic position of the south-west corner.
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
constexpr double getEast() const noexcept
Returns the easternmost longitude, in radians.
void setWest(double value) noexcept
Sets the westernmost longitude, in radians.
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.
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.
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.
static constexpr double degreesToRadians(double angleDegrees) noexcept
Converts degrees to radians.
Definition Math.h:325
static constexpr double TwoPi
Two times pi.
Definition Math.h:85
Classes for geospatial computations in Cesium.
STL namespace.
A 2D rectangle.
Definition Rectangle.h:14