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

Conversation

dtutic
Copy link

@dtutic dtutic commented Jul 20, 2018

TBD: webmerc is projection tied to WGS84 ellipsoid. Ideal would be that it is specified only with +webmerc without any additional parameter. Also if +R is given together with +ellps, output of -V option prints that +ellps is ignored, but correct final figure is printed. In projection implementation WGS 84 is forced no matter of values of +ellps or +R but this is not communicated with user who tries to use some other ellipsoid or sphere.

  1. Proposal is to rename full name of webmerc projection to "WGS 84 Web Mercator / WGS 84 Pseudo Mercator" instead of "Web Mercator / Pseudo Mercator"
    REASON: Official name of projection is "WGS 84 / Pseudo Mercator", see https://epsg.io/3857. Projection is tied to WGS 84 ellipsoid.

  2. webmerc projection for now is implemented as projection of a sphere. Consequences are that projection factors are calculated for Mercator projection of a sphere (i.e. no angular distortion) e.g.:

./proj +proj=webmerc +ellps=WGS84 -V
#Web Mercator / Pseudo Mercator
#	Cyl, Sph
#	
# +proj=webmerc +ellps=WGS84
#Final Earth figure: sphere
#  Radius: 6378137.000
0 0
Longitude: 0dE [ 0 ]
Latitude:  0dN [ 0 ]
Easting (x):   0.00
Northing (y):  0.00
Meridian scale (h) : 1.00000000  ( 2.319e-09 % error )
Parallel scale (k) : 1.00000000  ( 0 % error )
Areal scale (s):     1.00000000  ( 2.319e-09 % error )
Angular distortion (w): 0.000
Meridian/Parallel angle: 90.00000
Convergence : 0d [ -0.00000000 ]
Max-min (Tissot axis a-b) scale error: 1.00000 1.00000

These are not properties of Web Mercator projection which is non-conformal projection. This pull request gives implementation for ellipsoid, e.g.

PJ *PROJECTION(webmerc) {

    /* 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->inv = s_inverse;
    P->fwd = s_forward;
    return P;
}

which gives proper projection factors and final Earth figure, e.g.

./proj +proj=webmerc +ellps=WGS84 -V
#WGS 84 Web Mercator / WGS 84 Pseudo Mercator
#	Cyl, Ell
#	
# +proj=webmerc +ellps=WGS84
#Final Earth figure: ellipsoid
#  Major axis (a): 6378137.000
#  1/flattening: 298.257224
#  squared eccentricity: 0.006694379990
0 0
Longitude: 0dE [ 0 ]
Latitude:  0dN [ 0 ]
Easting (x):   0.00
Northing (y):  0.00
Meridian scale (h) : 1.00673950  ( 0.6739 % error )
Parallel scale (k) : 1.00000000  ( 0 % error )
Areal scale (s):     1.00673950  ( 0.6739 % error )
Angular distortion (w): 0.385
Meridian/Parallel angle: 90.00000
Convergence : 0d [ -0.00000000 ]
Max-min (Tissot axis a-b) scale error: 1.00674 1.00000

Also line

PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Sph\n\t";

is changed to

PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Ell\n\t";

because there is no (at least I am not aware of) definition of Web Mercator projection for sphere, so sphere should be avoided when we speak of Web Mercator projection. It is projection of rotational ellipsoid defined with specific equations which are chosen to be same as equations for Mercator of sphere, but it is different projection with different properties (cylindrical non-conformal, non-equareal, non-equidistant).

Avoiding introduction of sphere when talking and defining Web Mercator projection will remove confusion that user uses ellipsoid as reference surface but projection is for sphere (which, in fact, is not)!

  1. Updated description of Web Mercator projection to reflect its properties.

Dražen Tutić added 12 commits July 20, 2018 17:34
New webmerc (Web Mercator) projection was implemented as projection of a sphere. Consequences are that projection factors are calculated for Mercator projection of a sphere (i.e. no angular distortion) e.g.:

./proj +proj=webmerc +ellps=WGS84 -V
#Web Mercator / Pseudo Mercator
#	Cyl, Sph
#	
# +proj=webmerc +ellps=WGS84
#Final Earth figure: sphere
#  Radius: 6378137.000
0 0
Longitude: 0dE [ 0 ]
Latitude:  0dN [ 0 ]
Easting (x):   0.00
Northing (y):  0.00
Meridian scale (h) : 1.00000000  ( 2.319e-09 % error )
Parallel scale (k) : 1.00000000  ( 0 % error )
Areal scale (s):     1.00000000  ( 2.319e-09 % error )
Angular distortion (w): 0.000
Meridian/Parallel angle: 90.00000
Convergence : 0d [ -0.00000000 ]
Max-min (Tissot axis a-b) scale error: 1.00000 1.00000

These are not properties of Web Mercator projection which is non-conformal projection. It should be implemented for ellipsoid, e.g.

PJ *PROJECTION(webmerc) {

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

    P->inv = s_inverse;
    P->fwd = s_forward;
    return P;
}

which gives proper projection factors and final Earth figure, e.g.

./proj +proj=webmerc +ellps=WGS84 -V
#Web Mercator / Pseudo Mercator
#	Cyl, Ell
#	
# +proj=webmerc +ellps=WGS84
#Final Earth figure: ellipsoid
#  Major axis (a): 6378137.000
#  1/flattening: 298.257224
#  squared eccentricity: 0.006694379990
0 0
Longitude: 0dE [ 0 ]
Latitude:  0dN [ 0 ]
Easting (x):   0.00
Northing (y):  0.00
Meridian scale (h) : 1.00673950  ( 0.6739 % error )
Parallel scale (k) : 1.00000000  ( 0 % error )
Areal scale (s):     1.00673950  ( 0.6739 % error )
Angular distortion (w): 0.385
Meridian/Parallel angle: 90.00000
Convergence : 0d [ -0.00000000 ]
Max-min (Tissot axis a-b) scale error: 1.00674 1.00000

Also line

PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Sph\n\t";

should be

PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Ell\n\t";

because there is no (at least I am not aware of) definition of Web Mercator projection for sphere, so sphere should be avoided when we speak of Web Mercator projection. It is projection of rotational ellipsoid defined with specific equations which are chosen to be same as equations for Mercator of sphere, but it is different projection with different properties (cylindrical non-conformal, non-equareal, non-equidistant).

Avoiding introduction of sphere when talking and defining Web Mercator projection will remove confusion that user uses ellipsoid as reference surface but projection is for sphere (which, in fact, is not)!
Web Mercator projection is specific projection of rotational ellipsoid and is not defined for sphere. Therefore option +R should not be available for it, because one can confuse Web Mercator (non-conformal projection of rotational ellipsoid) with Mercator (conformal projection of sphere).
Web Mercator projection does not have any additional parameters, even the ellipsoid is fixed to WGS 84. This should be reflected in code, too. See its definition at: https://epsg.io/3857
Web Mercator is defined only for WGS 84 ellipsoid.
More precise name of Web Mercator or Pseudo Mercator is WGS 84 Web Mercator / WGS 84 Pseudo Mercator. This is its name in EPSG:3857 because it is tied to ellipsoid WGS 84. 

Of course, equations of that map projection can be applied to any ellipsoid, but then it is not any more Web Mercator projection as was designed.
@kbevers
Copy link
Member

kbevers commented Jul 20, 2018

Proposal is to rename full name of webmerc projection to "WGS 84 Web Mercator / WGS 84 Pseudo Mercator" instead of "Web Mercator / Pseudo Mercator"
REASON: Official name of projection is "WGS 84 / Pseudo Mercator", see epsg.io/3857. Projection is tied to WGS 84 ellipsoid.

I am not a fan of this proposal. The name you are refering to is a mix of reference frame and projection. Similar to "ETRS89/UTM Zone 32". That makes sense when you are describing a specific CRS in e.g. a catalogue like epsg.io but not when only talking about the projection (I agree that the waters are muddy here). In the EPSG guidance note 7 the projection is referred to as "Popular Visualisation Pseudo-Mercator ("Web Mercator")". Several other names are in use as well. So let's just stick with "Web Mercator". The ties to the WGS84 ellipsoid can be described in the documentation.

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

@dtutic
Copy link
Author

dtutic commented Jul 20, 2018 via email

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

@kbevers
Copy link
Member

kbevers commented Jul 20, 2018

Apart from my inlined comments and the thing about the name, I think this looks good. Solid first PR! Thanks for dealing with this.

@dtutic
Copy link
Author

dtutic commented Jul 20, 2018 via email

@dtutic
Copy link
Author

dtutic commented Jul 20, 2018 via email

@dtutic
Copy link
Author

dtutic commented Jul 20, 2018 via email

rouault added a commit to rouault/PROJ that referenced this pull request Aug 20, 2018
This is intended to supersed OSGeo#1080
with a number of differences.

What is kept from OSGeo#1080 is not forcing the ellipsoid_params to be the one
of a sphere. This is not required for correct coordinate computation and
avoid lying on the various distorsion parameters.

For better interoperability with EPSG, we also no longer force the phi0
and lam0 parameters to 0, because
https://www.epsg-registry.org/export.htm?gml=urn:ogc:def:method:EPSG::1024
has a provision for them, even if in practice they will always be zero

Another difference with the OSGeo#1080 approach is that we do not force the
WGS84 ellipsoid. Perhaps someone will use webmerc for another planet,
even if that is a crazy idea...
rouault added a commit to rouault/PROJ that referenced this pull request Aug 20, 2018
This is intended to supersed OSGeo#1080
with a number of differences.

What is kept from OSGeo#1080 is not forcing the ellipsoid_params to be the one
of a sphere. This is not required for correct coordinate computation and
avoid lying on the various distorsion parameters.

For better interoperability with EPSG, we also no longer force the
lam0 parameter to 0, because
https://www.epsg-registry.org/export.htm?gml=urn:ogc:def:method:EPSG::1024
has a provision for it, even if in practice they will always be zero
phi0 should always be zero and is not used by the formulas.

Another difference with the OSGeo#1080 approach is that we do not force the
WGS84 ellipsoid. Perhaps someone will use webmerc for another planet,
even if that is a crazy idea...
@rouault
Copy link
Member

rouault commented Aug 21, 2018

Was superseded by #1095

@rouault rouault closed this Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants