cesium-native 0.43.0
Loading...
Searching...
No Matches
GlobeRectangle.h
1#pragma once
2
3#include "Cartographic.h"
4#include "Library.h"
5
6#include <CesiumGeometry/Rectangle.h>
7#include <CesiumUtility/Math.h>
8
9#include <optional>
10
11namespace CesiumGeospatial {
12
24class CESIUMGEOSPATIAL_API GlobeRectangle final {
25public:
35 static const GlobeRectangle EMPTY;
36
46 static const GlobeRectangle MAXIMUM;
47
58 constexpr GlobeRectangle(
59 double west,
60 double south,
61 double east,
62 double north) noexcept
63 : _west(west), _south(south), _east(east), _north(north) {}
64
81 static constexpr GlobeRectangle fromDegrees(
82 double westDegrees,
83 double southDegrees,
84 double eastDegrees,
85 double northDegrees) noexcept {
86 return GlobeRectangle(
91 }
92
96 constexpr double getWest() const noexcept { return this->_west; }
97
101 void setWest(double value) noexcept { this->_west = value; }
102
106 constexpr double getSouth() const noexcept { return this->_south; }
107
111 void setSouth(double value) noexcept { this->_south = value; }
112
116 constexpr double getEast() const noexcept { return this->_east; }
117
121 void setEast(double value) noexcept { this->_east = value; }
122
126 constexpr double getNorth() const noexcept { return this->_north; }
127
131 void setNorth(double value) noexcept { this->_north = value; }
132
136 constexpr Cartographic getSouthwest() const noexcept {
137 return Cartographic(this->_west, this->_south);
138 }
139
143 constexpr Cartographic getSoutheast() const noexcept {
144 return Cartographic(this->_east, this->_south);
145 }
146
150 constexpr Cartographic getNorthwest() const noexcept {
151 return Cartographic(this->_west, this->_north);
152 }
153
157 constexpr Cartographic getNortheast() const noexcept {
158 return Cartographic(this->_east, this->_north);
159 }
160
164 constexpr CesiumGeometry::Rectangle toSimpleRectangle() const noexcept {
166 this->getWest(),
167 this->getSouth(),
168 this->getEast(),
169 this->getNorth());
170 }
171
177 constexpr double computeWidth() const noexcept {
178 double east = this->_east;
179 const double west = this->_west;
180 if (east < west) {
182 }
183 return east - west;
184 }
185
191 constexpr double computeHeight() const noexcept {
192 return this->_north - this->_south;
193 }
194
198 Cartographic computeCenter() const noexcept;
199
209 bool contains(const Cartographic& cartographic) const noexcept;
210
216 bool isEmpty() const noexcept;
217
233 std::optional<GlobeRectangle>
234 computeIntersection(const GlobeRectangle& other) const noexcept;
235
242 GlobeRectangle computeUnion(const GlobeRectangle& other) const noexcept;
243
254 std::pair<GlobeRectangle, std::optional<GlobeRectangle>>
255 splitAtAntiMeridian() const noexcept;
256
264 static bool
265 equals(const GlobeRectangle& left, const GlobeRectangle& right) noexcept;
266
276 static bool equalsEpsilon(
277 const GlobeRectangle& left,
278 const GlobeRectangle& right,
279 double relativeEpsilon) noexcept;
280
281private:
282 double _west;
283 double _south;
284 double _east;
285 double _north;
286};
287
288} // 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:320
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