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

peirce_q: rename +type parameter wrongly introduced in 8.2.1 to +shape (fixes #3011) #3014

Merged
merged 3 commits into from
Jan 11, 2022
Merged
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
8 changes: 4 additions & 4 deletions docs/plot/plotdefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand Down
28 changes: 16 additions & 12 deletions docs/source/operations/projections/peirce_q.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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
Expand All @@ -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.

Expand All @@ -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.*
Expand Down
19 changes: 18 additions & 1 deletion scripts/build_esri_projection_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,24 @@
- False_Northing: EPSG_NAME_PARAMETER_FALSE_NORTHING
- Central_Meridian: EPSG_NAME_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN

- Peirce_Quincuncial:
- WKT2_name: PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_SQUARE
Params:
- False_Easting: EPSG_NAME_PARAMETER_FALSE_EASTING
- False_Northing: EPSG_NAME_PARAMETER_FALSE_NORTHING
- Central_Meridian: EPSG_NAME_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN
- Scale_Factor: EPSG_NAME_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN
- Latitude_Of_Origin: EPSG_NAME_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN
- Option: 0.0

- WKT2_name: PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_DIAMOND
Params:
- False_Easting: EPSG_NAME_PARAMETER_FALSE_EASTING
- False_Northing: EPSG_NAME_PARAMETER_FALSE_NORTHING
- Central_Meridian: EPSG_NAME_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN
- Scale_Factor: EPSG_NAME_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN
- Latitude_Of_Origin: EPSG_NAME_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN
- Option: 1.0

# Missing/unclear mappings

Expand Down Expand Up @@ -748,7 +766,6 @@
# Polar_Stereographic_Variant_C
# Quartic_Authalic_Ellipsoidal
# Adams_Square_II
# Peirce_Quincuncial

"""

Expand Down
2 changes: 2 additions & 0 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10209,6 +10209,8 @@ PROJStringParser::Private::buildProjectedCRS(int iStep,
}
} else if (param->unit_type == UnitOfMeasure::Type::SCALE) {
value = 1;
} else if (step.name == "peirce_q" && proj_name == "lat_0") {
value = 90;
}

PropertyMap propertiesParameter;
Expand Down
24 changes: 24 additions & 0 deletions src/iso19111/operation/conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3839,6 +3839,30 @@ void Conversion::_exportToPROJString(
formatter->addParam("x_0", falseEasting);
formatter->addParam("y_0", falseNorthing);
bConversionDone = true;
} else if (ci_equal(methodName,
PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_SQUARE) ||
ci_equal(methodName,
PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_DIAMOND)) {
const auto &scaleFactor = parameterValueMeasure(
EPSG_CODE_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN);
if (scaleFactor.unit().type() != common::UnitOfMeasure::Type::UNKNOWN &&
std::fabs(scaleFactor.getSIValue() - 1.0) > 1e-10) {
throw io::FormattingException(
"Only scale factor = 1 handled for Peirce Quincuncial");
}
const double latitudeOfOriginDeg =
parameterValue(EPSG_CODE_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN)
->value()
.unit()
.type() != common::UnitOfMeasure::Type::UNKNOWN
? parameterValueNumeric(
EPSG_CODE_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN,
common::UnitOfMeasure::DEGREE)
: 90.0;
if (std::fabs(latitudeOfOriginDeg - 90.0) > 1e-10) {
throw io::FormattingException("Only latitude of natural origin = "
"90 handled for Peirce Quincuncial");
}
} else if (formatter->convention() ==
io::PROJStringFormatter::Convention::PROJ_5 &&
isZUnitConversion) {
Expand Down
31 changes: 31 additions & 0 deletions src/iso19111/operation/esriparammappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,33 @@ static const ESRIParamMapping paramsESRI_Equal_Earth[] = {
EPSG_CODE_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN, "0.0", false},
{nullptr, nullptr, 0, "0.0", false}};

static const ESRIParamMapping paramsESRI_Peirce_Quincuncial_alt1[] = {
{"False_Easting", EPSG_NAME_PARAMETER_FALSE_EASTING,
EPSG_CODE_PARAMETER_FALSE_EASTING, "0.0", false},
{"False_Northing", EPSG_NAME_PARAMETER_FALSE_NORTHING,
EPSG_CODE_PARAMETER_FALSE_NORTHING, "0.0", false},
{"Central_Meridian", EPSG_NAME_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN,
EPSG_CODE_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN, "0.0", false},
{"Scale_Factor", EPSG_NAME_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN,
EPSG_CODE_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN, "0.0", false},
{"Latitude_Of_Origin", EPSG_NAME_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN,
EPSG_CODE_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN, "0.0", false},
{"Option", nullptr, 0, "0.0", false},
{nullptr, nullptr, 0, "0.0", false}};
static const ESRIParamMapping paramsESRI_Peirce_Quincuncial_alt2[] = {
{"False_Easting", EPSG_NAME_PARAMETER_FALSE_EASTING,
EPSG_CODE_PARAMETER_FALSE_EASTING, "0.0", false},
{"False_Northing", EPSG_NAME_PARAMETER_FALSE_NORTHING,
EPSG_CODE_PARAMETER_FALSE_NORTHING, "0.0", false},
{"Central_Meridian", EPSG_NAME_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN,
EPSG_CODE_PARAMETER_LONGITUDE_OF_NATURAL_ORIGIN, "0.0", false},
{"Scale_Factor", EPSG_NAME_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN,
EPSG_CODE_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN, "0.0", false},
{"Latitude_Of_Origin", EPSG_NAME_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN,
EPSG_CODE_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN, "0.0", false},
{"Option", nullptr, 0, "1.0", false},
{nullptr, nullptr, 0, "0.0", false}};

static const ESRIMethodMapping esriMappings[] = {
{"Plate_Carree", EPSG_NAME_METHOD_EQUIDISTANT_CYLINDRICAL,
EPSG_CODE_METHOD_EQUIDISTANT_CYLINDRICAL, paramsESRI_Plate_Carree},
Expand Down Expand Up @@ -1115,6 +1142,10 @@ static const ESRIMethodMapping esriMappings[] = {
EPSG_CODE_METHOD_COLOMBIA_URBAN, paramsESRI_IGAC_Plano_Cartesiano},
{"Equal_Earth", EPSG_NAME_METHOD_EQUAL_EARTH, EPSG_CODE_METHOD_EQUAL_EARTH,
paramsESRI_Equal_Earth},
{"Peirce_Quincuncial", PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_SQUARE, 0,
paramsESRI_Peirce_Quincuncial_alt1},
{"Peirce_Quincuncial", PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_DIAMOND, 0,
paramsESRI_Peirce_Quincuncial_alt2},
};

// ---------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/iso19111/operation/parammappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,12 @@ static const MethodMapping projectionMethodMappings[] = {
{PROJ_WKT2_NAME_METHOD_ROBINSON, 0, "Robinson", "robin", nullptr,
paramsLonNatOriginLongitudeCentre},

{PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_SQUARE, 0, nullptr, "peirce_q",
"shape=square", paramsNatOriginScale},

{PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_DIAMOND, 0, nullptr, "peirce_q",
"shape=diamond", paramsNatOriginScale},

{PROJ_WKT2_NAME_METHOD_SINUSOIDAL, 0, "Sinusoidal", "sinu", nullptr,
paramsLonNatOriginLongitudeCentre},

Expand Down
3 changes: 3 additions & 0 deletions src/proj_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
#define EPSG_CODE_METHOD_COLOMBIA_URBAN 1052
#define EPSG_NAME_METHOD_COLOMBIA_URBAN "Colombia Urban"

#define PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_SQUARE "Peirce Quincuncial (Square)"
#define PROJ_WKT2_NAME_METHOD_PEIRCE_QUINCUNCIAL_DIAMOND "Peirce Quincuncial (Diamond)"

/* ------------------------------------------------------------------------ */

/* Projection parameters */
Expand Down
Loading