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

Freeze hard-coded prime meridians and note they are no longer updated #4042

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions docs/source/apps/cs2cs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ The following control parameters can appear in any order:

List of all ellipsoids that can be selected with the *+ellps* parameters.

.. option:: -lm

List of hard-coded prime meridians that can be selected with the *+pm* parameter.
mwtoews marked this conversation as resolved.
Show resolved Hide resolved

.. option:: -lu

List of all distance units that can be selected with the *+units* parameter.
Expand Down
3 changes: 2 additions & 1 deletion docs/source/development/reference/datatypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ List structures

.. c:type:: PJ_PRIME_MERIDIANS

Prime meridians defined in PROJ.
Hard-coded prime meridians defined in PROJ. Note that the structure is
no longer updated, and some values may conflict with other sources.

.. code-block:: C

Expand Down
3 changes: 2 additions & 1 deletion docs/source/development/reference/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ Lists

.. c:function:: const PJ_PRIME_MERIDIANS* proj_list_prime_meridians(void)

Get a pointer to an array of prime meridians defined in PROJ. The last
Get a pointer to an array of hard-coded prime meridians defined in PROJ.
Note that this list is no longer updated. The last
entry of the returned array is a NULL-entry. The array is statically
allocated and does not need to be freed after use.

Expand Down
24 changes: 13 additions & 11 deletions docs/source/usage/projections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,28 @@ Note that ``+over`` does **not** disable ``+lon_wrap``.
Prime Meridian
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A prime meridian may be declared indicating the offset between the prime
meridian of the declared coordinate system and that of greenwich. A prime
meridian is declared using the "pm" parameter, and may be assigned a symbolic
name, or the longitude of the alternative prime meridian relative to greenwich.
A prime meridian may be declared indicating the longitude offset between
the prime meridian of the declared coordinate system and that of greenwich.
A prime meridian is declared using the ``+pm`` parameter, and may be assigned
an angle in DMS or decimal degrees format, or as a hard-coded name.
mwtoews marked this conversation as resolved.
Show resolved Hide resolved

Currently prime meridian declarations are not used by the ``pj_inv()`` and
``pj_fwd()`` calls.
Consequently the user utility :program:`cs2cs` does honour prime meridians but
the :program:`proj` user utility ignores them.

The following predeclared prime meridian names are supported. These can be
listed using with ``cs2cs -lm``.
Hard-coded prime meridians can be listed with ``cs2cs -lm``.
Note that the following list is no longer updated, and some values
may conflict with other sources.

=========== ================
Meridian Longitude
=========== ================
greenwich 0dE
lisbon 9d07'54.862"W
paris 2d20'14.025"E
bogota 74d04'51.3"E
madrid 3d41'16.48"W
bogota 74d04'51.3"W
madrid 3d41'16.58"W
rome 12d27'8.4"E
bern 7d26'22.5"E
jakarta 106d48'27.79"E
Expand All @@ -164,17 +165,18 @@ listed using with ``cs2cs -lm``.
stockholm 18d3'29.8"E
athens 23d42'58.815"E
oslo 10d43'22.5"E
copenhagen 12d34'40.35"E
=========== ================

Example of use. The location ``long=0``, ``lat=0`` in the greenwich based lat/long
coordinates is translated to lat/long coordinates with Madrid as the prime
coordinates is translated to lat/long coordinates with Lisbon as the prime
meridian.

::

cs2cs +proj=latlong +datum=WGS84 +to +proj=latlong +datum=WGS84 +pm=madrid
cs2cs +proj=latlong +datum=WGS84 +to +proj=latlong +datum=WGS84 +pm=lisbon
0 0
3d41'16.48"E 0dN 0.000
9d7'54.862"E 0dN 0.000


Axis orientation
Expand Down
4 changes: 3 additions & 1 deletion src/apps/cs2cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,10 @@ int main(int argc, char **argv) {
}
proj_unit_list_destroy(units);
} else if (arg[1] == 'm') { /* list prime meridians */
(void)fprintf(stderr,
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't emit a warning. If we want to emit one, then we should also do it for datum, ellipsoid, units, etc

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the second sentence "This list is no longer updated, and some values may conflict with other sources"

Copy link
Member Author

Choose a reason for hiding this comment

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

Listing datums was already removed (e9605e4).
Listing ellipsoids could potentially show a similar message.
Listing units uses proj_get_units_from_database so is fine.

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to disregard my comments. I'm not that strong about them.

The only thing that is a bit weird is that internally PROJ still creates PROJ pipeline strings with those deprecated features, but one could argue that is an implementation detail. Well, actually not completely true, as we also export that to the sight of the advanced user...)

$ bin/projinfo -s "NTF (Paris)" -t "NTF" -o PROJ -q
+proj=pipeline
  +step +proj=axisswap +order=2,1
  +step +proj=unitconvert +xy_in=grad +xy_out=rad
  +step +inv +proj=longlat +ellps=clrk80ign +pm=paris
  +step +proj=unitconvert +xy_in=rad +xy_out=deg
  +step +proj=axisswap +order=2,1

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's fine to have a short list of hard-coded of prime meridians (e.g. where paris ↔ 2.33722917) with the caveat that it doesn't change. It's a bit deprecated, but I wasn't planning to establish this as a deprecated feature. But yes, I can tone down the "legacy PROJ.4" wording throughout.

Copy link
Member

Choose a reason for hiding this comment

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

The above pipeline could also have +pm expressed in decimal degrees, so the PROJ internals could be changed to do that in the future, should we decide to drop support for these hard-coded lists.

"This list is no longer updated, and some values may "
"conflict with other sources.\n");
const struct PJ_PRIME_MERIDIANS *lpm;

for (lpm = proj_list_prime_meridians(); lpm->id; ++lpm)
(void)printf("%12s %-30s\n", lpm->id, lpm->defn);
} else
Expand Down
9 changes: 7 additions & 2 deletions src/datums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ static const struct PJ_DATUMS pj_datums[] = {

const struct PJ_DATUMS *pj_get_datums_ref() { return pj_datums; }

/*
* This list is no longer updated, and some values may conflict with
* other sources.
*/

static const struct PJ_PRIME_MERIDIANS pj_prime_meridians[] = {
/* id definition */
/* -- ---------- */
{"greenwich", "0dE"},
{"lisbon", "9d07'54.862\"W"},
{"paris", "2d20'14.025\"E"},
{"bogota", "74d04'51.3\"W"},
{"madrid", "3d41'16.58\"W"},
{"madrid", "3d41'16.58\"W"}, /* EPSG:8905 is 3d41'14.55"W */
{"rome", "12d27'8.4\"E"},
{"bern", "7d26'22.5\"E"},
{"jakarta", "106d48'27.79\"E"},
Expand All @@ -79,7 +84,7 @@ static const struct PJ_PRIME_MERIDIANS pj_prime_meridians[] = {
{"stockholm", "18d3'29.8\"E"},
{"athens", "23d42'58.815\"E"},
{"oslo", "10d43'22.5\"E"},
{"copenhagen", "12d34'40.35\"E"},
{"copenhagen", "12d34'40.35\"E"}, /* EPSG:1026 is 12d34'39.9"E */
{nullptr, nullptr}};

const PJ_PRIME_MERIDIANS *proj_list_prime_meridians(void) {
Expand Down
3 changes: 2 additions & 1 deletion test/unit/gie_self_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ TEST(gie, info_functions) {
n = 0;
for (pm_list = proj_list_prime_meridians(); pm_list->id; ++pm_list)
n++;
ASSERT_NE(n, 0U);
/* hard-coded prime meridians are not updated; expect a fixed size */
EXPECT_EQ(n, 14U);
}

// ---------------------------------------------------------------------------
Expand Down