cesium-native 0.43.0
Loading...
Searching...
No Matches
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.
 
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.
 
constexpr double computeHeight () const noexcept
 Computes the height of this rectangle.
 
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.
 
bool isEmpty () const noexcept
 Determines if this rectangle is empty.
 
std::optional< GlobeRectanglecomputeIntersection (const GlobeRectangle &other) const noexcept
 Computes the intersection of two rectangles.
 
GlobeRectangle computeUnion (const GlobeRectangle &other) const noexcept
 Computes the union of this globe rectangle with another.
 
std::pair< GlobeRectangle, std::optional< GlobeRectangle > > splitAtAntiMeridian () const noexcept
 Splits this rectangle at the anti-meridian (180 degrees longitude), if necessary.
 

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.
 
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.
 

Static Public Attributes

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

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()

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()

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()

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.

Definition at line 81 of file GlobeRectangle.h.

◆ getEast()

double CesiumGeospatial::GlobeRectangle::getEast ( ) const
inlineconstexprnoexcept

Returns the easternmost longitude, in radians.

Definition at line 116 of file GlobeRectangle.h.

◆ getNorth()

double CesiumGeospatial::GlobeRectangle::getNorth ( ) const
inlineconstexprnoexcept

Returns the northernmost latitude, in radians.

Definition at line 126 of file GlobeRectangle.h.

◆ getNortheast()

Cartographic CesiumGeospatial::GlobeRectangle::getNortheast ( ) const
inlineconstexprnoexcept

Returns the Cartographic position of the north-east corner.

Definition at line 157 of file GlobeRectangle.h.

◆ getNorthwest()

Cartographic CesiumGeospatial::GlobeRectangle::getNorthwest ( ) const
inlineconstexprnoexcept

Returns the Cartographic position of the north-west corner.

Definition at line 150 of file GlobeRectangle.h.

◆ getSouth()

double CesiumGeospatial::GlobeRectangle::getSouth ( ) const
inlineconstexprnoexcept

Returns the southernmost latitude, in radians.

Definition at line 106 of file GlobeRectangle.h.

◆ getSoutheast()

Cartographic CesiumGeospatial::GlobeRectangle::getSoutheast ( ) const
inlineconstexprnoexcept

Returns the Cartographic position of the south-east corner.

Definition at line 143 of file GlobeRectangle.h.

◆ getSouthwest()

Cartographic CesiumGeospatial::GlobeRectangle::getSouthwest ( ) const
inlineconstexprnoexcept

Returns the Cartographic position of the south-west corner.

Definition at line 136 of file GlobeRectangle.h.

◆ getWest()

double CesiumGeospatial::GlobeRectangle::getWest ( ) const
inlineconstexprnoexcept

Returns the westernmost longitude, in radians.

Definition at line 96 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.

◆ setEast()

void CesiumGeospatial::GlobeRectangle::setEast ( double value)
inlinenoexcept

Sets the easternmost longitude, in radians.

Definition at line 121 of file GlobeRectangle.h.

◆ setNorth()

void CesiumGeospatial::GlobeRectangle::setNorth ( double value)
inlinenoexcept

Sets the northernmost latitude, in radians.

Definition at line 131 of file GlobeRectangle.h.

◆ setSouth()

void CesiumGeospatial::GlobeRectangle::setSouth ( double value)
inlinenoexcept

Sets the southernmost latitude, in radians.

Definition at line 111 of file GlobeRectangle.h.

◆ setWest()

void CesiumGeospatial::GlobeRectangle::setWest ( double value)
inlinenoexcept

Sets the westernmost longitude, in radians.

Definition at line 101 of file GlobeRectangle.h.

◆ 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.

◆ toSimpleRectangle()

CesiumGeometry::Rectangle CesiumGeospatial::GlobeRectangle::toSimpleRectangle ( ) const
inlineconstexprnoexcept

Returns this rectangle as a CesiumGeometry::Rectangle.

Definition at line 164 of file GlobeRectangle.h.

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: