cesium-native 0.44.2
Loading...
Searching...
No Matches
GeographicProjection.h
1#pragma once
2
3#include <CesiumGeospatial/Ellipsoid.h>
4#include <CesiumGeospatial/GlobeRectangle.h>
5#include <CesiumGeospatial/Library.h>
6#include <CesiumUtility/Math.h>
7
8#include <glm/vec2.hpp>
9#include <glm/vec3.hpp>
10
11namespace CesiumGeospatial {
12
13class Cartographic;
14
26class CESIUMGEOSPATIAL_API GeographicProjection final {
27public:
33 static constexpr GlobeRectangle MAXIMUM_GLOBE_RECTANGLE = GlobeRectangle(
38
48 const Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID) noexcept {
49 const double longitudeValue =
50 ellipsoid.getMaximumRadius() * CesiumUtility::Math::OnePi;
51 const double latitudeValue =
52 ellipsoid.getMaximumRadius() * CesiumUtility::Math::PiOverTwo;
54 -longitudeValue,
55 -latitudeValue,
56 longitudeValue,
57 latitudeValue);
58 }
59
66 const Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID) noexcept;
67
71 const Ellipsoid& getEllipsoid() const noexcept { return this->_ellipsoid; }
72
83 glm::dvec3 project(const Cartographic& cartographic) const noexcept;
84
94 project(const CesiumGeospatial::GlobeRectangle& rectangle) const noexcept;
95
107 Cartographic unproject(const glm::dvec2& projectedCoordinates) const noexcept;
108
120 Cartographic unproject(const glm::dvec3& projectedCoordinates) const noexcept;
121
131 unproject(const CesiumGeometry::Rectangle& rectangle) const noexcept;
132
136 bool operator==(const GeographicProjection& rhs) const noexcept {
137 return this->_ellipsoid == rhs._ellipsoid;
138 };
139
144 bool operator!=(const GeographicProjection& rhs) const noexcept {
145 return !(*this == rhs);
146 };
147
148private:
149 Ellipsoid _ellipsoid;
150 double _semimajorAxis;
151 double _oneOverSemimajorAxis;
152};
153
154} // namespace CesiumGeospatial
A position defined by longitude, latitude, and height.
A quadratic surface defined in Cartesian coordinates.
Definition Ellipsoid.h:39
A map projection where longitude and latitude are mapped using an Ellipsoid.
bool operator!=(const GeographicProjection &rhs) const noexcept
Returns true if two projections (i.e. their ellipsoids) are not equal.
bool operator==(const GeographicProjection &rhs) const noexcept
Returns true if two projections (i.e. their ellipsoids) are equal.
Cartographic unproject(const glm::dvec3 &projectedCoordinates) const noexcept
Converts geographic coordinates to geodetic ellipsoid coordinates.
CesiumGeospatial::GlobeRectangle unproject(const CesiumGeometry::Rectangle &rectangle) const noexcept
Unprojects a geographic rectangle to the globe.
const Ellipsoid & getEllipsoid() const noexcept
Gets the Ellipsoid.
static constexpr CesiumGeometry::Rectangle computeMaximumProjectedRectangle(const Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84) noexcept
Computes the maximum rectangle that can be covered with this projection.
CesiumGeometry::Rectangle project(const CesiumGeospatial::GlobeRectangle &rectangle) const noexcept
Projects a globe rectangle to geographic coordinates.
Cartographic unproject(const glm::dvec2 &projectedCoordinates) const noexcept
Converts geographic coordinates to geodetic ellipsoid coordinates.
GeographicProjection(const Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84) noexcept
Constructs a new instance.
glm::dvec3 project(const Cartographic &cartographic) const noexcept
Converts geodedic ellipsoid coordinates to geographic coordinates.
A two-dimensional, rectangular region on a globe, specified using longitude and latitude coordinates....
static constexpr double PiOverTwo
Pi divided by two.
Definition Math.h:90
static constexpr double OnePi
Pi.
Definition Math.h:80
Classes for geospatial computations in Cesium.
A 2D rectangle.
Definition Rectangle.h:14