[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.3-4-g4d142be

git at osgeo.org git at osgeo.org
Mon Feb 8 12:46:21 PST 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  4d142be96dc0a44519e2599e6fd46ce02fcbdf5a (commit)
       via  552d774211f992033d61743e03bc3ae31b0df638 (commit)
      from  b2ad18b3cfbc2624beea7b31e318058406b7d160 (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 4d142be96dc0a44519e2599e6fd46ce02fcbdf5a
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Feb 8 12:46:14 2021 -0800

    Update NEWS

diff --git a/NEWS b/NEWS
index 4d78466..4cfa533 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PostGIS 3.0.3
   - #4748, Fix incorrect axis swapping in polar stereographic (Paul Ramsey)
   - #4727, Fix bug in geocentrix box computation (Paul Ramsey)
   - #4790, Fix ST_3dintersects calculations with identical vertices (Nicklas Avén)
+  - #4817, Handle complex compound coordinate systems (Paul Ramsey)
 
 PostGIS 3.0.2
 2020/08/15

commit 552d774211f992033d61743e03bc3ae31b0df638
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Feb 5 15:27:56 2021 -0800

    Handle more deeply nested CRS objects when extracting CS objects to find axis ordering. References #4817

diff --git a/liblwgeom/lwgeom_transform.c b/liblwgeom/lwgeom_transform.c
index 06559f4..cc684bd 100644
--- a/liblwgeom/lwgeom_transform.c
+++ b/liblwgeom/lwgeom_transform.c
@@ -211,34 +211,66 @@ projpj_from_string(const char *str1)
 
 #else /* POSTGIS_PROJ_VERION >= 60 */
 
-static uint8_t
-proj_crs_is_swapped(const PJ *pj_crs)
+static PJ *
+proj_cs_get_simplecs(const PJ *pj_crs)
 {
-	PJ *pj_cs;
-	uint8_t rv = LW_FALSE;
-
+	PJ *pj_sub = NULL;
 	if (proj_get_type(pj_crs) == PJ_TYPE_COMPOUND_CRS)
 	{
-		PJ *pj_horiz_crs = proj_crs_get_sub_crs(NULL, pj_crs, 0);
-		if (!pj_horiz_crs)
-			lwerror("%s: proj_crs_get_sub_crs returned NULL", __func__);
-		pj_cs = proj_crs_get_coordinate_system(NULL, pj_horiz_crs);
-		proj_destroy(pj_horiz_crs);
+		/* Sub-CRS[0] is the horizontal component */
+		pj_sub = proj_crs_get_sub_crs(NULL, pj_crs, 0);
+		if (!pj_sub)
+			lwerror("%s: proj_crs_get_sub_crs(0) returned NULL", __func__);
 	}
 	else if (proj_get_type(pj_crs) == PJ_TYPE_BOUND_CRS)
 	{
-		PJ *pj_src_crs = proj_get_source_crs(NULL, pj_crs);
-		if (!pj_src_crs)
+		pj_sub = proj_get_source_crs(NULL, pj_crs);
+		if (!pj_sub)
 			lwerror("%s: proj_get_source_crs returned NULL", __func__);
-		pj_cs = proj_crs_get_coordinate_system(NULL, pj_src_crs);
-		proj_destroy(pj_src_crs);
 	}
 	else
 	{
-		pj_cs = proj_crs_get_coordinate_system(NULL, pj_crs);
+		/* If this works, we have a CS so we can return */
+		pj_sub = proj_crs_get_coordinate_system(NULL, pj_crs);
+		if (pj_sub)
+			return pj_sub;
+	}
+
+	/* Only sub-components of the Compound or Bound CRS's get here */
+	/* If we failed to get sub-components, or we failed to extract */
+	/* a CS from a generic CRS, then this is another case we don't */
+	/* handle */
+	if (!pj_sub)
+		lwerror("%s: %s", __func__, proj_errno_string(proj_context_errno(NULL)));
+
+	/* If the components are usable, we can extract the CS and return */
+	int pj_type = proj_get_type(pj_sub);
+	if (pj_type == PJ_TYPE_GEOGRAPHIC_2D_CRS || pj_type == PJ_TYPE_PROJECTED_CRS)
+	{
+		PJ *pj_2d = proj_crs_get_coordinate_system(NULL, pj_sub);
+		proj_destroy(pj_sub);
+		return pj_2d;
+	}
+
+	/* If the components are *themselves* Bound/Compound, we can recurse */
+	if (pj_type == PJ_TYPE_COMPOUND_CRS || pj_type == PJ_TYPE_BOUND_CRS)
+		return proj_cs_get_simplecs(pj_sub);
+
+	/* This is a case we don't know how to handle */
+	lwerror("%s: un-handled CRS sub-type: %s", __func__, pj_type);
+	return NULL;
+}
+
+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__);
 	}
-	if (!pj_cs)
-		lwerror("%s: proj_crs_get_coordinate_system returned NULL", __func__);
 	int axis_count = proj_cs_get_axis_count(NULL, pj_cs);
 	if (axis_count > 0)
 	{

-----------------------------------------------------------------------

Summary of changes:
 NEWS                         |  1 +
 liblwgeom/lwgeom_transform.c | 66 ++++++++++++++++++++++++++++++++------------
 2 files changed, 50 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list