The map projection used by Google Maps, Bing Maps, and most of ArcGIS Online, EPSG:3857.
More...
#include <CesiumGeospatial/WebMercatorProjection.h>
|
static const double | MAXIMUM_LATITUDE |
| The maximum latitude (both North and South) supported by a Web Mercator (EPSG:3857) projection. More...
|
|
static const GlobeRectangle | MAXIMUM_GLOBE_RECTANGLE |
| The maximum bounding rectangle of the Web Mercator projection, ranging from -PI to PI radians longitude and from -MAXIMUM_LATITUDE to +MAXIMUM_LATITUDE.
|
|
The map projection used by Google Maps, Bing Maps, and most of ArcGIS Online, EPSG:3857.
This projection uses geodetic longitude and latitude expressed with WGS84 and transforms them to Mercator using the spherical (rather than ellipsoidal) equations.
- See also
- GeographicProjection
Definition at line 24 of file WebMercatorProjection.h.
◆ WebMercatorProjection()
CesiumGeospatial::WebMercatorProjection::WebMercatorProjection |
( |
const Ellipsoid &ellipsoid |
CESIUM_DEFAULT_ELLIPSOID | ) |
|
|
noexcept |
Constructs a new instance.
- Parameters
-
◆ computeMaximumProjectedRectangle()
static constexpr CesiumGeometry::Rectangle CesiumGeospatial::WebMercatorProjection::computeMaximumProjectedRectangle |
( |
const Ellipsoid &ellipsoid |
CESIUM_DEFAULT_ELLIPSOID | ) |
|
|
inlinestaticconstexprnoexcept |
Computes the maximum rectangle that can be covered with this projection.
- Parameters
-
- Returns
- The rectangle
Definition at line 57 of file WebMercatorProjection.h.
◆ geodeticLatitudeToMercatorAngle()
static double CesiumGeospatial::WebMercatorProjection::geodeticLatitudeToMercatorAngle |
( |
double |
latitude | ) |
|
|
staticnoexcept |
Converts a geodetic latitude in radians, in the range -PI/2 to PI/2, to a Mercator angle in the range -PI to PI.
- Parameters
-
latitude | The geodetic latitude in radians. |
- Returns
- The Mercator angle.
◆ mercatorAngleToGeodeticLatitude()
static double CesiumGeospatial::WebMercatorProjection::mercatorAngleToGeodeticLatitude |
( |
double |
mercatorAngle | ) |
|
|
staticnoexcept |
Converts a Mercator angle, in the range -PI to PI, to a geodetic latitude in the range -PI/2 to PI/2.
- Parameters
-
mercatorAngle | The angle to convert. |
- Returns
- The geodetic latitude in radians.
◆ project() [1/2]
glm::dvec3 CesiumGeospatial::WebMercatorProjection::project |
( |
const Cartographic & |
cartographic | ) |
const |
|
noexcept |
Converts geodedic ellipsoid coordinates to Web Mercator coordinates.
Converts geodetic ellipsoid coordinates, in radians, to the equivalent Web Mercator X, Y, Z coordinates expressed in meters. The height is copied unmodified to the z
coordinate.
- Parameters
-
cartographic | The geodetic coordinates in radians. |
- Returns
- The equivalent web mercator X, Y, Z coordinates, in meters.
◆ project() [2/2]
Projects a globe rectangle to Web Mercator coordinates.
This is done by projecting the southwest and northeast corners.
- Parameters
-
rectangle | The globe rectangle to project. |
- Returns
- The projected rectangle.
◆ unproject() [1/3]
Unprojects a Web Mercator rectangle to the globe.
This is done by unprojecting the southwest and northeast corners.
- Parameters
-
rectangle | The rectangle to unproject. |
- Returns
- The unprojected rectangle.
◆ unproject() [2/3]
Cartographic CesiumGeospatial::WebMercatorProjection::unproject |
( |
const glm::dvec2 & |
projectedCoordinates | ) |
const |
|
noexcept |
Converts Web Mercator coordinates to geodetic ellipsoid coordinates.
Converts Web Mercator X and Y coordinates, expressed in meters, to a Cartographic containing geodetic ellipsoid coordinates. The height is set to 0.0.
- Parameters
-
projectedCoordinates | The web mercator projected coordinates to unproject. |
- Returns
- The equivalent cartographic coordinates.
◆ unproject() [3/3]
Cartographic CesiumGeospatial::WebMercatorProjection::unproject |
( |
const glm::dvec3 & |
projectedCoordinates | ) |
const |
|
noexcept |
Converts Web Mercator coordinates to geodetic ellipsoid coordinates.
Converts Web Mercator X, Y coordinates, expressed in meters, to a Cartographic containing geodetic ellipsoid coordinates. The Z coordinate is copied unmodified to the height.
- Parameters
-
projectedCoordinates | The web mercator projected coordinates to unproject, with height (z) in meters. |
- Returns
- The equivalent cartographic coordinates.
◆ MAXIMUM_LATITUDE
const double CesiumGeospatial::WebMercatorProjection::MAXIMUM_LATITUDE |
|
static |
The maximum latitude (both North and South) supported by a Web Mercator (EPSG:3857) projection.
Technically, the Mercator projection is defined for any latitude up to (but not including) 90 degrees, but it makes sense to cut it off sooner because it grows exponentially with increasing latitude. The logic behind this particular cutoff value, which is the one used by Google Maps, Bing Maps, and Esri, is that it makes the projection square. That is, the rectangle is equal in the X and Y directions.
The constant value is computed by calling: CesiumGeospatial::WebMercatorProjection::mercatorAngleToGeodeticLatitude(CesiumUtility::Math::OnePi)
Definition at line 40 of file WebMercatorProjection.h.
The documentation for this class was generated from the following file: