cesium-native  0.41.0
CesiumGeospatial::GlobeRectangle Class Referencefinal

A two-dimensional, rectangular region on a globe, specified using longitude and latitude coordinates. The region is rectangular in terms of longitude-latitude coordinates, but may be far from rectangular on the actual globe surface. More...

#include <CesiumGeospatial/GlobeRectangle.h>

Public Member Functions

constexpr GlobeRectangle (double west, double south, double east, double north) noexcept
 Constructs a new instance. More...
 
constexpr double getWest () const noexcept
 Returns the westernmost longitude, in radians.
 
void setWest (double value) noexcept
 Sets the westernmost longitude, in radians.
 
constexpr double getSouth () const noexcept
 Returns the southernmost latitude, in radians.
 
void setSouth (double value) noexcept
 Sets the southernmost latitude, in radians.
 
constexpr double getEast () const noexcept
 Returns the easternmost longitude, in radians.
 
void setEast (double value) noexcept
 Sets the easternmost longitude, in radians.
 
constexpr double getNorth () const noexcept
 Returns the northernmost latitude, in radians.
 
void setNorth (double value) noexcept
 Sets the northernmost latitude, in radians.
 
constexpr Cartographic getSouthwest () const noexcept
 Returns the Cartographic position of the south-west corner.
 
constexpr Cartographic getSoutheast () const noexcept
 Returns the Cartographic position of the south-east corner.
 
constexpr Cartographic getNorthwest () const noexcept
 Returns the Cartographic position of the north-west corner.
 
constexpr Cartographic getNortheast () const noexcept
 Returns the Cartographic position of the north-east corner.
 
constexpr CesiumGeometry::Rectangle toSimpleRectangle () const noexcept
 Returns this rectangle as a CesiumGeometry::Rectangle.
 
constexpr double computeWidth () const noexcept
 Computes the width of this rectangle. More...
 
constexpr double computeHeight () const noexcept
 Computes the height of this rectangle. More...
 
Cartographic computeCenter () const noexcept
 Computes the Cartographic center position of this rectangle.
 
bool contains (const Cartographic &cartographic) const noexcept
 Returns true if this rectangle contains the given point. More...
 
bool isEmpty () const noexcept
 Determines if this rectangle is empty. More...
 
std::optional< GlobeRectanglecomputeIntersection (const GlobeRectangle &other) const noexcept
 Computes the intersection of two rectangles. More...
 
GlobeRectangle computeUnion (const GlobeRectangle &other) const noexcept
 Computes the union of this globe rectangle with another. More...
 
std::pair< GlobeRectangle, std::optional< GlobeRectangle > > splitAtAntiMeridian () const noexcept
 Splits this rectangle at the anti-meridian (180 degrees longitude), if necessary. More...
 

Static Public Member Functions

static constexpr GlobeRectangle fromDegrees (double westDegrees, double southDegrees, double eastDegrees, double northDegrees) noexcept
 
static bool equals (const GlobeRectangle &left, const GlobeRectangle &right) noexcept
 Checks whether two globe rectangles are exactly equal. More...
 
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. More...
 

Static Public Attributes

static const GlobeRectangle EMPTY
 An empty rectangle. More...
 
static const GlobeRectangle MAXIMUM
 The maximum rectangle. More...
 

Detailed Description

A two-dimensional, rectangular region on a globe, specified using longitude and latitude coordinates. The region is rectangular in terms of longitude-latitude coordinates, but may be far from rectangular on the actual globe surface.

The eastern coordinate may be less than the western coordinate, which indicates that the rectangle crosses the anti-meridian.

See also
CesiumGeometry::Rectangle

Definition at line 24 of file GlobeRectangle.h.

Constructor & Destructor Documentation

◆ GlobeRectangle()

constexpr CesiumGeospatial::GlobeRectangle::GlobeRectangle ( double  west,
double  south,
double  east,
double  north 
)
inlineconstexprnoexcept

Constructs a new instance.

Parameters
westThe westernmost longitude, in radians, in the range [-Pi, Pi].
southThe southernmost latitude, in radians, in the range [-Pi/2, Pi/2].
eastThe easternmost longitude, in radians, in the range [-Pi, Pi].
northThe northernmost latitude, in radians, in the range [-Pi/2, Pi/2].

Definition at line 58 of file GlobeRectangle.h.

Member Function Documentation

◆ computeHeight()

constexpr double CesiumGeospatial::GlobeRectangle::computeHeight ( ) const
inlineconstexprnoexcept

Computes the height of this rectangle.

The result will be in radians, in the range [0, Pi*2].

Definition at line 191 of file GlobeRectangle.h.

◆ computeIntersection()

std::optional<GlobeRectangle> CesiumGeospatial::GlobeRectangle::computeIntersection ( const GlobeRectangle other) const
noexcept

Computes the intersection of two rectangles.

This function assumes that the rectangle's coordinates are latitude and longitude in radians and produces a correct intersection, taking into account the fact that the same angle can be represented with multiple values as well as the wrapping of longitude at the anti-meridian. For a simple intersection that ignores these factors and can be used with projected coordinates, see CesiumGeometry::Rectangle::computeIntersection.

Parameters
otherThe other rectangle to intersect with this one.
Returns
The intersection rectangle, or std::nullopt if there is no intersection.

◆ computeUnion()

GlobeRectangle CesiumGeospatial::GlobeRectangle::computeUnion ( const GlobeRectangle other) const
noexcept

Computes the union of this globe rectangle with another.

Parameters
otherThe other globe rectangle.
Returns
The union.

◆ computeWidth()

constexpr double CesiumGeospatial::GlobeRectangle::computeWidth ( ) const
inlineconstexprnoexcept

Computes the width of this rectangle.

The result will be in radians, in the range [0, Pi*2].

Definition at line 177 of file GlobeRectangle.h.

◆ contains()

bool CesiumGeospatial::GlobeRectangle::contains ( const Cartographic cartographic) const
noexcept

Returns true if this rectangle contains the given point.

The provided cartographic position must be within the longitude range [-Pi, Pi] and the latitude range [-Pi/2, Pi/2].

This will take into account the wrapping of the longitude at the anti-meridian.

◆ equals()

static bool CesiumGeospatial::GlobeRectangle::equals ( const GlobeRectangle left,
const GlobeRectangle right 
)
staticnoexcept

Checks whether two globe rectangles are exactly equal.

Parameters
leftThe first rectangle.
rightThe second rectangle.
Returns
Whether the rectangles are equal

◆ equalsEpsilon()

static bool CesiumGeospatial::GlobeRectangle::equalsEpsilon ( const GlobeRectangle left,
const GlobeRectangle right,
double  relativeEpsilon 
)
staticnoexcept

Checks whether two globe rectangles are equal up to a given relative epsilon.

Parameters
leftThe first rectangle.
rightThe second rectangle.
relativeEpsilonThe relative epsilon.
Returns
Whether the rectangles are epsilon-equal

◆ fromDegrees()

static constexpr GlobeRectangle CesiumGeospatial::GlobeRectangle::fromDegrees ( double  westDegrees,
double  southDegrees,
double  eastDegrees,
double  northDegrees 
)
inlinestaticconstexprnoexcept

Creates a rectangle given the boundary longitude and latitude in degrees. The angles are converted to radians.

Parameters
westDegreesThe westernmost longitude in degrees in the range [-180.0, 180.0].
southDegreesThe southernmost latitude in degrees in the range [-90.0, 90.0].
eastDegreesThe easternmost longitude in degrees in the range [-180.0, 180.0].
northDegreesThe northernmost latitude in degrees in the range [-90.0, 90.0].
Returns
The rectangle.
A two-dimensional, rectangular region on a globe, specified using longitude and latitude coordinates....
static constexpr GlobeRectangle fromDegrees(double westDegrees, double southDegrees, double eastDegrees, double northDegrees) noexcept

Definition at line 81 of file GlobeRectangle.h.

◆ isEmpty()

bool CesiumGeospatial::GlobeRectangle::isEmpty ( ) const
noexcept

Determines if this rectangle is empty.

An empty rectangle bounds no part of the globe, not even a single point.

◆ splitAtAntiMeridian()

std::pair<GlobeRectangle, std::optional<GlobeRectangle> > CesiumGeospatial::GlobeRectangle::splitAtAntiMeridian ( ) const
noexcept

Splits this rectangle at the anti-meridian (180 degrees longitude), if necessary.

If the rectangle does not cross the anti-meridian, the entire rectangle is returned in the first field of the pair and the second is std::nullopt. If it does cross the anti-meridian, this function returns two rectangles that touch but do not cross it. The larger of the two rectangles is returned in first and the smaller one is returned in second.

Member Data Documentation

◆ EMPTY

const GlobeRectangle CesiumGeospatial::GlobeRectangle::EMPTY
static

An empty rectangle.

The rectangle has the following values:

  • west: Pi
  • south: Pi/2
  • east: -Pi
  • north: -Pi/2

Definition at line 35 of file GlobeRectangle.h.

◆ MAXIMUM

const GlobeRectangle CesiumGeospatial::GlobeRectangle::MAXIMUM
static

The maximum rectangle.

The rectangle has the following values:

  • west: -Pi
  • south: -Pi/2
  • east: Pi
  • north: Pi/2

Definition at line 46 of file GlobeRectangle.h.


The documentation for this class was generated from the following file: