diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2022-01-07 15:32:12 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2022-01-07 16:49:11 +0100 |
| commit | cf5aef989b65ed857ed03d2ed3de447daaffe5a3 (patch) | |
| tree | 5f0c24402ae21cf1eab3ba7b90b89c98651a4a7f | |
| parent | a03d3c16222ed4aed121d26bdf6db5fbf72ddeb0 (diff) | |
| download | PROJ-cf5aef989b65ed857ed03d2ed3de447daaffe5a3.tar.gz PROJ-cf5aef989b65ed857ed03d2ed3de447daaffe5a3.zip | |
peirce_q: rename +type parameter wrongly introduced in 8.2.1 to +shape (fixes #3011)
| -rw-r--r-- | docs/plot/plotdefs.json | 8 | ||||
| -rw-r--r-- | docs/source/operations/projections/peirce_q.rst | 28 | ||||
| -rw-r--r-- | src/projections/adams.cpp | 52 | ||||
| -rw-r--r-- | test/gie/peirce_q.gie | 16 |
4 files changed, 54 insertions, 50 deletions
diff --git a/docs/plot/plotdefs.json b/docs/plot/plotdefs.json index a6d70273..f55f5e0a 100644 --- a/docs/plot/plotdefs.json +++ b/docs/plot/plotdefs.json @@ -1057,7 +1057,7 @@ "lonmax": 180, "lonmin": -180, "name": "peirce_q_square", - "projstring": "+proj=peirce_q +lon_0=25 +type=square", + "projstring": "+proj=peirce_q +lon_0=25 +shape=square", "res": "low", "type": "poly" }, @@ -1068,7 +1068,7 @@ "lonmax": 180, "lonmin": -180, "name": "peirce_q", - "projstring": "+proj=peirce_q +lon_0=25 +type=diamond", + "projstring": "+proj=peirce_q +lon_0=25 +shape=diamond", "res": "low", "type": "poly" }, @@ -1079,7 +1079,7 @@ "lonmax": 180, "lonmin": -180, "name": "peirce_q_horizontal", - "projstring": "+proj=peirce_q +lon_0=25 +type=horizontal", + "projstring": "+proj=peirce_q +lon_0=25 +shape=horizontal", "res": "low", "type": "line" }, @@ -1090,7 +1090,7 @@ "lonmax": 180, "lonmin": -180, "name": "grieger_triptychial", - "projstring": "+proj=pipeline +step +proj=ob_tran +o_proj=peirce_q +o_lat_p=-45 +o_lon_p=45 +type=horizontal +scrollx=-0.25 +step +proj=affine +s11=-1 +s12=0 +s21=0 +s22=-1", + "projstring": "+proj=pipeline +step +proj=ob_tran +o_proj=peirce_q +o_lat_p=-45 +o_lon_p=45 +shape=horizontal +scrollx=-0.25 +step +proj=affine +s11=-1 +s12=0 +s21=0 +s22=-1", "res": "low", "type": "poly" }, diff --git a/docs/source/operations/projections/peirce_q.rst b/docs/source/operations/projections/peirce_q.rst index cf972932..57504032 100644 --- a/docs/source/operations/projections/peirce_q.rst +++ b/docs/source/operations/projections/peirce_q.rst @@ -14,10 +14,10 @@ defaults to a central meridian of 0, it is more common to use a central meridian of around 25 to optimise the distortions. Peirce's original published map from 1879 used a central meridian of approx -70. The diamond and square versions can be produced using the -``+type=diamond`` and ``+type=square`` options respectively. +``+shape=diamond`` and ``+shape=square`` options respectively. This implementation includes an alternative lateral projection -which places hemispheres side-by-side (``+type=horizontal`` or -``+type=vertical``). Combined with a general oblique transformation, +which places hemispheres side-by-side (``+shape=horizontal`` or +``+shape=vertical``). Combined with a general oblique transformation, this can be used to produced a Grieger Triptychial projection (see example below). @@ -43,21 +43,21 @@ this can be used to produced a Grieger Triptychial projection :align: center :alt: Peirce Quincuncial (Square) - proj-string: ``+proj=peirce_q +lon_0=25 +type=square`` + proj-string: ``+proj=peirce_q +lon_0=25 +shape=square`` .. figure:: ./images/peirce_q_diamond.png :width: 500 px :align: center :alt: Peirce Quincuncial (Diamond) - proj-string: ``+proj=peirce_q +lon_0=25 +type=diamond`` + proj-string: ``+proj=peirce_q +lon_0=25 +shape=diamond`` .. figure:: ./images/peirce_q_horizontal.png :width: 500 px :align: center :alt: Peirce Quincuncial (Horizontal) - proj-string: ``+proj=peirce_q +lon_0=25 +type=horizontal`` + proj-string: ``+proj=peirce_q +lon_0=25 +shape=horizontal`` .. figure:: ./images/grieger_triptychial.png :width: 500 px @@ -73,16 +73,20 @@ Parameters .. include:: ../options/lon_0.rst -.. option:: +type=square/diamond/horizontal/vertical/nhemisphere/shemisphere +.. option:: +shape=square/diamond/horizontal/vertical/nhemisphere/shemisphere - .. versionadded:: 8.2.1 + .. versionadded:: 9.0 *Defaults to diamond.* - Indicates the type of transformation applied to the southern hemisphere: + .. warning:: This option was wrongly introduced introduced in 8.2.1 with the + ``type`` name, which was inappropriate as it conflicted with + the ``+type=crs`` general hint. + + Indicates the shape of transformation applied to the southern hemisphere: ``square`` and ``diamond`` represent the traditional quincuncial form suggested by Peirce with the southern hemisphere divided into 4 triangles and reflected - outward from the northern hemisphere. The ``square`` type is rotated by 45 + outward from the northern hemisphere. The ``square`` shape is rotated by 45 degrees to produce the conventional square presentation. The origin lies at the centre of the square or diamond. @@ -96,14 +100,14 @@ Parameters .. option:: +scrollx=<value> - For ``horizontal`` type allows a scalar circular scroll of resulting x coordinates + For ``horizontal`` shape allows a scalar circular scroll of resulting x coordinates to shift sections of the projection to the other horizontal side of the map. *Defaults to 0.0. Must be a scale between -1.0 and 1.0.* .. option:: +scrolly=<value> - For ``vertical`` type allows a scalar circular scroll of resulting y coordinates + For ``vertical`` shape allows a scalar circular scroll of resulting y coordinates to shift sections of the projection to the other vertical side of the map. *Defaults to 0.0. Must be a scale between -1.0 and 1.0.* diff --git a/src/projections/adams.cpp b/src/projections/adams.cpp index 4150fff2..f991e7c2 100644 --- a/src/projections/adams.cpp +++ b/src/projections/adams.cpp @@ -60,7 +60,7 @@ enum projection_type { ADAMS_WS2, }; -enum peirce_type { +enum peirce_shape { PEIRCE_Q_SQUARE, PEIRCE_Q_DIAMOND, PEIRCE_Q_NHEMISPHERE, @@ -71,7 +71,7 @@ enum peirce_type { struct pj_opaque { projection_type mode; - peirce_type pqtype; + peirce_shape pqshape; double scrollx = 0.0; double scrolly = 0.0; }; @@ -143,13 +143,13 @@ static PJ_XY adams_forward(PJ_LP lp, PJ *P) { break; case PEIRCE_Q: { /* lam0 - note that the original Peirce model used a central meridian of around -70deg, but the default within proj is +lon0=0 */ - if (Q->pqtype == PEIRCE_Q_NHEMISPHERE) { + if (Q->pqshape == PEIRCE_Q_NHEMISPHERE) { if( lp.phi < -TOL ) { proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); return proj_coord_error().xy; } } - if (Q->pqtype == PEIRCE_Q_SHEMISPHERE) { + if (Q->pqshape == PEIRCE_Q_SHEMISPHERE) { if( lp.phi > -TOL ) { proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); return proj_coord_error().xy; @@ -211,7 +211,7 @@ static PJ_XY adams_forward(PJ_LP lp, PJ *P) { constexpr double shd = 1.8540746773013719 * 2; /* For square and diamond Quincuncial projections, spin out southern hemisphere to triangular segments of quincunx (before rotation for square)*/ - if( Q->pqtype == PEIRCE_Q_SQUARE || ( Q->pqtype == PEIRCE_Q_DIAMOND )) { + if( Q->pqshape == PEIRCE_Q_SQUARE || ( Q->pqshape == PEIRCE_Q_DIAMOND )) { if (lp.phi < 0.) { /* fold out segments */ if (lp.lam < ( -0.75 * M_PI )) xy.y = shd - xy.y; /* top left segment, shift up and reflect y */ if ( (lp.lam < (-0.25 * M_PI)) && (lp.lam >= ( -0.75 * M_PI ))) xy.x = - shd - xy.x; /* left segment, shift left and reflect x */ @@ -222,20 +222,20 @@ static PJ_XY adams_forward(PJ_LP lp, PJ *P) { } /* For square types rotate xy by 45 deg */ - if( Q->pqtype == PEIRCE_Q_SQUARE ) { + if( Q->pqshape == PEIRCE_Q_SQUARE ) { const double temp = xy.x; xy.x = RSQRT2 * (xy.x - xy.y); xy.y = RSQRT2 * (temp + xy.y); } /* For rectangle Quincuncial projs, spin out southern hemisphere to east (horizontal) or north (vertical) after rotation */ - if( Q->pqtype == PEIRCE_Q_HORIZONTAL ) { + if( Q->pqshape == PEIRCE_Q_HORIZONTAL ) { if (lp.phi < 0.) { xy.x = shd - xy.x; /* reflect x to east */ } xy.x = xy.x - (shd / 2); /* shift everything so origin is in middle of two hemispheres */ } - if( Q->pqtype == PEIRCE_Q_VERTICAL ) { + if( Q->pqshape == PEIRCE_Q_VERTICAL ) { if (lp.phi < 0.) { xy.y = shd - xy.y; /* reflect y to north */ } @@ -243,7 +243,7 @@ static PJ_XY adams_forward(PJ_LP lp, PJ *P) { } //if o_scrollx param present, scroll x - if (!(Q->scrollx == 0.0) && (Q->pqtype == PEIRCE_Q_HORIZONTAL) ) { + if (!(Q->scrollx == 0.0) && (Q->pqshape == PEIRCE_Q_HORIZONTAL) ) { double xscale = 2.0; double xthresh = shd / 2; xy.x = xy.x + (Q->scrollx * (xthresh * 2 * xscale)); /*shift relative to proj width*/ @@ -256,7 +256,7 @@ static PJ_XY adams_forward(PJ_LP lp, PJ *P) { } //if o_scrolly param present, scroll y - if (!(Q->scrolly == 0.0) && (Q->pqtype == PEIRCE_Q_VERTICAL)) { + if (!(Q->scrolly == 0.0) && (Q->pqshape == PEIRCE_Q_VERTICAL)) { double yscale = 2.0; double ythresh = shd / 2; xy.y = xy.y + (Q->scrolly * (ythresh * 2 * yscale)); /*shift relative to proj height*/ @@ -316,25 +316,25 @@ static PJ *setup(PJ *P, projection_type mode) { P->inv = adams_inverse; if( mode == PEIRCE_Q) { - // Quincuncial projections type options: square, diamond, hemisphere, horizontal (rectangle) or vertical (rectangle) - const char* pqtype = pj_param (P->ctx, P->params, "stype").s; + // Quincuncial projections shape options: square, diamond, hemisphere, horizontal (rectangle) or vertical (rectangle) + const char* pqshape = pj_param (P->ctx, P->params, "sshape").s; - if (!pqtype) pqtype = "diamond"; /* default if type value not supplied */ + if (!pqshape) pqshape = "diamond"; /* default if shape value not supplied */ - if (strcmp(pqtype, "square") == 0) { - Q->pqtype = PEIRCE_Q_SQUARE; + if (strcmp(pqshape, "square") == 0) { + Q->pqshape = PEIRCE_Q_SQUARE; } - else if (strcmp(pqtype, "diamond") == 0) { - Q->pqtype = PEIRCE_Q_DIAMOND; + else if (strcmp(pqshape, "diamond") == 0) { + Q->pqshape = PEIRCE_Q_DIAMOND; } - else if (strcmp(pqtype, "nhemisphere") == 0) { - Q->pqtype = PEIRCE_Q_NHEMISPHERE; + else if (strcmp(pqshape, "nhemisphere") == 0) { + Q->pqshape = PEIRCE_Q_NHEMISPHERE; } - else if (strcmp(pqtype, "shemisphere") == 0) { - Q->pqtype = PEIRCE_Q_SHEMISPHERE; + else if (strcmp(pqshape, "shemisphere") == 0) { + Q->pqshape = PEIRCE_Q_SHEMISPHERE; } - else if (strcmp(pqtype, "horizontal") == 0) { - Q->pqtype = PEIRCE_Q_HORIZONTAL; + else if (strcmp(pqshape, "horizontal") == 0) { + Q->pqshape = PEIRCE_Q_HORIZONTAL; if (pj_param(P->ctx, P->params, "tscrollx").i) { double scrollx; scrollx = pj_param(P->ctx, P->params, "dscrollx").f; @@ -345,8 +345,8 @@ static PJ *setup(PJ *P, projection_type mode) { Q->scrollx = scrollx; } } - else if (strcmp(pqtype, "vertical") == 0) { - Q->pqtype = PEIRCE_Q_VERTICAL; + else if (strcmp(pqshape, "vertical") == 0) { + Q->pqshape = PEIRCE_Q_VERTICAL; if (pj_param(P->ctx, P->params, "tscrolly").i) { double scrolly; scrolly = pj_param(P->ctx, P->params, "dscrolly").f; @@ -358,7 +358,7 @@ static PJ *setup(PJ *P, projection_type mode) { } } else { - proj_log_error (P, _("peirce_q: invalid value for 'type' parameter")); + proj_log_error (P, _("peirce_q: invalid value for 'shape' parameter")); return pj_default_destructor (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); } diff --git a/test/gie/peirce_q.gie b/test/gie/peirce_q.gie index 713d2581..fbd771a5 100644 --- a/test/gie/peirce_q.gie +++ b/test/gie/peirce_q.gie @@ -14,7 +14,7 @@ ------------------------------------------------------------ ------------------------------------------------------------ -operation +proj=peirce_q +R=6370997 +type=square +operation +proj=peirce_q +R=6370997 +shape=square tolerance 10 mm ------------------------------------------------------------ @@ -138,7 +138,7 @@ accept 170.3972098164 87.6222109978 expect -153172.25 215556.52 ------------------------------------------------------------ - operation +proj=peirce_q +R=6370997 +type=diamond + operation +proj=peirce_q +R=6370997 +shape=diamond tolerance 10 mm ------------------------------------------------------------ @@ -262,7 +262,7 @@ accept 170.3972098164 87.6222109978 expect 44112.34 260730.62 ------------------------------------------------------------ -operation +proj=peirce_q +R=6370997 +type=horizontal +operation +proj=peirce_q +R=6370997 +shape=horizontal tolerance 10 mm ------------------------------------------------------------ @@ -386,7 +386,7 @@ accept 170.3972098164 87.6222109978 expect -11768191.87 260730.62 ------------------------------------------------------------ - operation +proj=peirce_q +R=6370997 +type=horizontal +scrollx=0.75 + operation +proj=peirce_q +R=6370997 +shape=horizontal +scrollx=0.75 tolerance 10 mm ------------------------------------------------------------ @@ -510,7 +510,7 @@ accept 170.3972098164 87.6222109978 expect -23580496.07 260730.62 ------------------------------------------------------------ - operation +proj=peirce_q +R=6370997 +type=vertical + operation +proj=peirce_q +R=6370997 +shape=vertical tolerance 10 mm ------------------------------------------------------------ @@ -634,7 +634,7 @@ accept 170.3972098164 87.6222109978 expect 44112.34 -11551573.59 ------------------------------------------------------------ - operation +proj=peirce_q +R=6370997 +type=vertical +scrolly=-0.25 + operation +proj=peirce_q +R=6370997 +shape=vertical +scrolly=-0.25 tolerance 10 mm ------------------------------------------------------------ @@ -758,7 +758,7 @@ accept 170.3972098164 87.6222109978 expect 44112.34 -23363877.80 ------------------------------------------------------------ - operation +proj=peirce_q +R=6370997 +type=nhemisphere + operation +proj=peirce_q +R=6370997 +shape=nhemisphere tolerance 10 mm ------------------------------------------------------------ @@ -882,7 +882,7 @@ accept 170.3972098164 87.6222109978 expect 44112.34 260730.62 ------------------------------------------------------------ - operation +proj=peirce_q +R=6370997 +type=shemisphere + operation +proj=peirce_q +R=6370997 +shape=shemisphere tolerance 10 mm ------------------------------------------------------------ |
