cesium-native 0.43.0
Loading...
Searching...
No Matches
GeographicProjection.h
1#pragma once
2
3#include "Ellipsoid.h"
4#include "GlobeRectangle.h"
5#include "Library.h"
6
7#include <CesiumUtility/Math.h>
8
9#include <glm/vec2.hpp>
10#include <glm/vec3.hpp>
11
12namespace CesiumGeospatial {
13
14class Cartographic;
15
27class CESIUMGEOSPATIAL_API GeographicProjection final {
28public:
34 static constexpr GlobeRectangle MAXIMUM_GLOBE_RECTANGLE = GlobeRectangle(
39
49 const Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID) noexcept {
50 const double longitudeValue =
51 ellipsoid.getMaximumRadius() * CesiumUtility::Math::OnePi;
52 const double latitudeValue =
53 ellipsoid.getMaximumRadius() * CesiumUtility::Math::PiOverTwo;
55 -longitudeValue,
56 -latitudeValue,
57 longitudeValue,
58 latitudeValue);
59 }
60
67 const Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID) noexcept;
68
72 const Ellipsoid& getEllipsoid() const noexcept { return this->_ellipsoid; }
73
84 glm::dvec3 project(const Cartographic& cartographic) const noexcept;
85
95 project(const CesiumGeospatial::GlobeRectangle& rectangle) const noexcept;
96
108 Cartographic unproject(const glm::dvec2& projectedCoordinates) const noexcept;
109
121 Cartographic unproject(const glm::dvec3& projectedCoordinates) const noexcept;
122
132 unproject(const CesiumGeometry::Rectangle& rectangle) const noexcept;
133
137 bool operator==(const GeographicProjection& rhs) const noexcept {
138 return this->_ellipsoid == rhs._ellipsoid;
139 };
140
145 bool operator!=(const GeographicProjection& rhs) const noexcept {
146 return !(*this == rhs);
147 };
148
149private:
150 Ellipsoid _ellipsoid;
151 double _semimajorAxis;
152 double _oneOverSemimajorAxis;
153};
154
155} // namespace CesiumGeospatial
A position defined by longitude, latitude, and height.
A quadratic surface defined in Cartesian coordinates.
Definition Ellipsoid.h:38
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 divded 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