Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of webmerc projection #1080

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions docs/source/operations/projections/webmerc.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
.. _webmerc:

********************************************************************************
Web Mercator / Pseudo Mercator
WGS 84 Web Mercator / WGS 84 Pseudo Mercator
********************************************************************************

.. versionadded:: 5.1.0

The Web Mercator / Pseudo Mercator projection is a cylindrical map projection.
This is a variant of the regular :ref:`merc` projection, except that the computation
is done on a sphere, using the semi-major axis of the ellipsoid.
The WGS 84 Web Mercator / WGS 84 Pseudo Mercator projection is a cylindrical map projection.
It is defined only for ellipsoid WGS 84, motivated by the regular :ref:`merc` projection, but the equations for the ellispoid are chosen to be the same as equations for Mercator projection of a sphere, with radius same as semi-major axis of the WGS 84 ellipsoid. As a consequence it is not a conformal projection.

From `Wikipedia <https://en.wikipedia.org/wiki/Web_Mercator>`_:

Expand All @@ -21,21 +20,21 @@ From `Wikipedia <https://en.wikipedia.org/wiki/Web_Mercator>`_:
historically.


+---------------------+----------------------------------------------------------+
| **Classification** | Cylindrical (non conformant if used with ellipsoid) |
+---------------------+----------------------------------------------------------+
| **Available forms** | Forward and inverse, spherical projection |
+---------------------+----------------------------------------------------------+
| **Defined area** | Global, but best used near the equator |
+---------------------+----------------------------------------------------------+
| **Alias** | webmerc |
+---------------------+----------------------------------------------------------+
| **Domain** | 2D |
+---------------------+----------------------------------------------------------+
| **Input type** | Geodetic coordinates |
+---------------------+----------------------------------------------------------+
| **Output type** | Projected coordinates |
+---------------------+----------------------------------------------------------+
+---------------------+-----------------------------------------------------------------+
| **Classification** | Non-conformal cylindrical projection of an WGS 84 ellipsoid |
+---------------------+-----------------------------------------------------------------+
| **Available forms** | Forward and inverse, ellipsoidal projection |
+---------------------+-----------------------------------------------------------------+
| **Defined area** | Global, low linear distortions near the equator |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to just say that it is globally defined and not go into where distortions are at a minimum. The original text is just a copy of what's written for Mercator which is kind of not valid here anyway.

+---------------------+-----------------------------------------------------------------+
| **Alias** | webmerc |
+---------------------+-----------------------------------------------------------------+
| **Domain** | 2D |
+---------------------+-----------------------------------------------------------------+
| **Input type** | Geodetic coordinates |
+---------------------+-----------------------------------------------------------------+
| **Output type** | Projected coordinates |
+---------------------+-----------------------------------------------------------------+


Usage
Expand All @@ -49,13 +48,8 @@ Example::
Parameters
################################################################################

.. note:: All parameters for the projection are optional.
.. note:: Projection does not have any additional parameters. See `EPSG.io <http://epsg.io/3857>`_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to refer to Wikipedia here? The epsg.io site doesn't go into much detail. Also, it is easily mistaken as official outlet of the EPSG (which it is not). It is already mentioned under "Further reading".


.. include:: ../options/R.rst

.. include:: ../options/x_0.rst

.. include:: ../options/y_0.rst

Mathematical definition
#######################
Expand Down
16 changes: 10 additions & 6 deletions src/PJ_merc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "projects.h"

PROJ_HEAD(merc, "Mercator") "\n\tCyl, Sph&Ell\n\tlat_ts=";
PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Sph\n\t";
PROJ_HEAD(webmerc, "WGS 84 Web Mercator / WGS 84 Pseudo Mercator") "\n\tCyl, Ell\n\t";

#define EPS10 1.e-10
static double logtanpfpim1(double x) { /* log(tan(x/2 + M_FORTPI)) */
Expand Down Expand Up @@ -92,15 +92,19 @@ PJ *PROJECTION(merc) {

PJ *PROJECTION(webmerc) {

/* Overriding k_0, lat_0 and lon_0 with fixed parameters */
/* Overriding k_0, lat_0, lon_0, x_0 and y_0 with fixed parameters */
P->k0 = 1.0;
P->phi0 = 0.0;
P->lam0 = 0.0;
P->x0 = 0;
P->y0 = 0;

/* Overriding ellipsoid and using WGS 84 */
P->f = 1.0/298.257223563;
P->a = 6378137.0;
P->es = P->f*(2-P->f);
pj_calc_ellipsoid_params (P, P->a, P->es);

P->b = P->a;
/* Clean up the ellipsoidal parameters to reflect the sphere */
P->es = P->e = P->f = 0;
pj_calc_ellipsoid_params (P, P->a, 0);
P->inv = s_inverse;
P->fwd = s_forward;
return P;
Expand Down
2 changes: 1 addition & 1 deletion src/pj_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PROJ_HEAD(wag4, "Wagner IV")
PROJ_HEAD(wag5, "Wagner V")
PROJ_HEAD(wag6, "Wagner VI")
PROJ_HEAD(wag7, "Wagner VII")
PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator")
PROJ_HEAD(webmerc, "WGS 84 Web Mercator / WGS 84 Pseudo Mercator")
PROJ_HEAD(weren, "Werenskiold I")
PROJ_HEAD(wink1, "Winkel I")
PROJ_HEAD(wink2, "Winkel II")
Expand Down