[postgis-tickets] [SCM] PostGIS branch stable-3.1 updated. 3.1.1-5-g9ab60a6
git at osgeo.org
git at osgeo.org
Mon Feb 8 12:28:25 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.1 has been updated
via 9ab60a647dcba6815d943393622465e1939f9a90 (commit)
via 11efb9f0cdc71cf2bdc4850491218495a07b18ba (commit)
from 2785f60d36e62e69b23f2bc953eb25cd3482097a (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 9ab60a647dcba6815d943393622465e1939f9a90
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Mon Feb 8 12:28:19 2021 -0800
Update NEWS
diff --git a/NEWS b/NEWS
index 8e2f191..cedacf6 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PostGIS 3.1.2
- #4826, postgis_tiger_geocoder Better answers when no zip is provided
(Regina Obe)
+ - #4817, handle more complex compound coordinate dystems (Paul Ramsey)
PostGIS 3.1.1
commit 11efb9f0cdc71cf2bdc4850491218495a07b18ba
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 973b0a9..ed7d601 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