[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.3-23-g6a831ee
git at osgeo.org
git at osgeo.org
Wed Jul 14 10:12:27 PDT 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, stable-3.0 has been updated
via 6a831ee189f6b4d763631695f82b226375f72018 (commit)
from 27ae21c50959e85d5b2695174cb4fd4f767b0f76 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6a831ee189f6b4d763631695f82b226375f72018
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Jul 14 10:12:21 2021 -0700
Flip N/E systems to E/N and geodetic systems to Lon/Lat, while leaving Polar systems as-is, references #4949, 3.0 branch
diff --git a/NEWS b/NEWS
index 96a0b17..72e3fb2 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PostGIS 3.0.4dev
- #4844, Repair axis order handling for polar coordinate systems (Paul Ramsey)
- #4863, Update bboxes after scale/affine coordinate changes (Paul Ramsey)
- #4918, Fix rare crash in st_minpossiblevalue() (Paul Ramsey)
+ - #4949, Swapped coordinates for N/E planar systems (Paul Ramsey)
PostGIS 3.0.3
diff --git a/liblwgeom/lwgeom_transform.c b/liblwgeom/lwgeom_transform.c
index 49b7415..78672d8 100644
--- a/liblwgeom/lwgeom_transform.c
+++ b/liblwgeom/lwgeom_transform.c
@@ -261,42 +261,64 @@ proj_cs_get_simplecs(const PJ *pj_crs)
return NULL;
}
+
+#define STR_EQUALS(A, B) strcmp((A), (B)) == 0
+#define STR_IEQUALS(A, B) (strcasecmp((A), (B)) == 0)
+#define STR_ISTARTS(A, B) (strncasecmp((A), (B), strlen((B))) == 0)
+
static uint8_t
proj_crs_is_swapped(const PJ *pj_crs)
{
- PJ *pj_cs;
- uint8_t rv = LW_FALSE;
-
- pj_cs = proj_cs_get_simplecs(pj_crs);
- if (!pj_cs) {
- lwerror("%s: proj_cs_get_simplecs returned NULL", __func__);
- }
- int axis_count = proj_cs_get_axis_count(NULL, pj_cs);
- if (axis_count > 0)
- {
- const char *out_name, *out_abbrev, *out_direction;
- double out_unit_conv_factor;
- const char *out_unit_name, *out_unit_auth_name, *out_unit_code;
- /* Read only first axis, see if it is degrees / north */
- proj_cs_get_axis_info(NULL,
- pj_cs,
- 0,
- &out_name,
- &out_abbrev,
- &out_direction,
- &out_unit_conv_factor,
- &out_unit_name,
- &out_unit_auth_name,
- &out_unit_code);
- /* Only swap Lat/Lon systems */
- /* Use whatever ordering planar systems default to */
- if (strcasecmp(out_abbrev, "Lat") == 0)
- rv = LW_TRUE;
- else
- rv = LW_FALSE;
- }
- proj_destroy(pj_cs);
- return rv;
+ int axis_count;
+ PJ *pj_cs = proj_cs_get_simplecs(pj_crs);
+ if (!pj_cs)
+ lwerror("%s: proj_cs_get_simplecs returned NULL", __func__);
+
+ axis_count = proj_cs_get_axis_count(NULL, pj_cs);
+ if (axis_count >= 2)
+ {
+ const char *out_name1, *out_abbrev1, *out_direction1;
+ const char *out_name2, *out_abbrev2, *out_direction2;
+ /* Read first axis */
+ proj_cs_get_axis_info(NULL,
+ pj_cs, 0,
+ &out_name1, &out_abbrev1, &out_direction1,
+ NULL, NULL, NULL, NULL);
+ /* Read second axis */
+ proj_cs_get_axis_info(NULL,
+ pj_cs, 1,
+ &out_name2, &out_abbrev2, &out_direction2,
+ NULL, NULL, NULL, NULL);
+
+ proj_destroy(pj_cs);
+
+ /* Directions agree, this is a northing/easting CRS, so reverse it */
+ if(out_direction1 && STR_IEQUALS(out_direction1, "north") &&
+ out_direction2 && STR_IEQUALS(out_direction2, "east") )
+ {
+ return LW_TRUE;
+ }
+
+ /* Oddball case? Both axes north / both axes south, swap */
+ if(out_direction1 && out_direction2 &&
+ ((STR_IEQUALS(out_direction1, "north") && STR_IEQUALS(out_direction2, "north")) ||
+ (STR_IEQUALS(out_direction1, "south") && STR_IEQUALS(out_direction2, "south"))) &&
+ out_name1 && STR_ISTARTS(out_name1, "northing") &&
+ out_name2 && STR_ISTARTS(out_name2, "easting"))
+ {
+ return LW_TRUE;
+ }
+
+ /* Any lat/lon system with Lat in first axis gets swapped */
+ if (STR_ISTARTS(out_abbrev1, "Lat"))
+ return LW_TRUE;
+
+ return LW_FALSE;
+ }
+
+ /* Failed the axis count test, leave quietly */
+ proj_destroy(pj_cs);
+ return LW_FALSE;
}
LWPROJ *
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index 267adfd..9b44624 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1334,3 +1334,25 @@ SELECT '#4863', st_contains(geometry, st_scale(st_orientedenvelope(geometry),
6755733.56891884,-141934.403428904 6755716.1146343,-141971.698204552
6755713.77835553,-141972.789895508 6755731.24770785))'::geometry as
geometry) x;
+
+-- New Zealand forward -- SRID=2193;POINT(1766289 5927325)
+SELECT '#4949', 'NZ forward', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=4326;POINT(174.863597538742 -36.785298415230315)'::geometry, 2193),0.1));
+--- New Zealand inverse (opposite EPSG order) -- SRID=4326;POINT(174.863598 -36.785298)
+SELECT '#4949', 'NZ inverse', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=2193;POINT(1766289 5927325)'::geometry, 4326),0.000001));
+-- British Columbia forward (respect EPSG order) -- SRID=3005;POINT(1286630.44 561883.98)
+SELECT '#4949', 'BC forward', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=4269;POINT(-122 50)'::geometry, 3005),0.01));
+-- British Columbia inverse (respect EPSG order) -- SRID=4269;POINT(-122 50)
+SELECT '#4949', 'BC inverse', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=3005;POINT(1286630.44 561883.98)'::geometry, 4269),0.000001));
+-- North Pole LAEA Europe inverse -- SRID=4326;POINT(19.4921659 69.7902258)
+SELECT '#4949', 'North Pole LAEA inverse', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=3575;POINT(370182 -2213980)'::geometry,4326),0.0000001));
+-- Polar Stereographic forward -- SRID=3413;POINT(2218082.1 -1409150)
+SELECT '#4949', 'Arctic Stereographic forward', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=4326;POINT(12.572160 66.081084)'::geometry,3413),0.1));
+-- Antarctic Polar Stereographic -- SRID=3031;POINT(-2399498.7 3213318.5)
+SELECT '#4949', 'Antarctic Stereographic forward', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
+ 'SRID=4326;POINT(-36.75 -54.25)'::geometry, 3031),0.1));
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index f3ff300..9641025 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -441,3 +441,10 @@ ERROR: LWGEOM_addpoint: Invalid offset
#4853|0
#4844|SRID=4326;POINT(19.49 69.79)
#4863|t
+#4949|NZ forward|SRID=2193;POINT(1766289 5927325)
+#4949|NZ inverse|SRID=4326;POINT(174.863598 -36.785298)
+#4949|BC forward|SRID=3005;POINT(1286630.44 561883.98)
+#4949|BC inverse|SRID=4269;POINT(-122 50)
+#4949|North Pole LAEA inverse|SRID=4326;POINT(19.4921659 69.7902258)
+#4949|Arctic Stereographic forward|SRID=3413;POINT(2218082.1 -1409150)
+#4949|Antarctic Stereographic forward|SRID=3031;POINT(-2399498.7 3213318.5)
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
liblwgeom/lwgeom_transform.c | 88 +++++++++++++++++++++++++++----------------
regress/core/tickets.sql | 22 +++++++++++
regress/core/tickets_expected | 7 ++++
4 files changed, 85 insertions(+), 33 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list