[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-49-gd92c6b7

git at osgeo.org git at osgeo.org
Wed Apr 1 01:02:53 PDT 2020


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, master has been updated
       via  d92c6b7cf4b3c8078b6ffcbc59a91462db57f92a (commit)
      from  697a9bd99cb3ebce7ba5bcdb685f35dc18b9a591 (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 d92c6b7cf4b3c8078b6ffcbc59a91462db57f92a
Author: Raúl Marín <git at rmr.ninja>
Date:   Tue Mar 31 15:48:09 2020 +0200

    Support casting a geojson text to geometry
    
    Closes https://github.com/postgis/postgis/pull/551
    Closes #4656

diff --git a/NEWS b/NEWS
index f771baf..e655f2e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,13 +7,13 @@ Only tickets not included in 3.1.0alpha1
   -
 
 * New features *
-  -
+  - #4656, Cast a geojson_text::geometry for implicit GeoJSON ingestion (Raúl Marín)
 
 * Enhancements *
-  - #4651: ST_Simplify: Don't copy if nothing is removed
+  - #4651: ST_Simplify: Don't copy if nothing is removed (Raúl Marín)
 
 * Bug fixes *
-  - #4652, Fix several memory related bugs in ST_GeomFromGML
+  - #4652, Fix several memory related bugs in ST_GeomFromGML (Raúl Marín)
 
 PostGIS 3.1.0alpha1
 2020/02/01
diff --git a/postgis/lwgeom_inout.c b/postgis/lwgeom_inout.c
index be4b2ee..3a31a2d 100644
--- a/postgis/lwgeom_inout.c
+++ b/postgis/lwgeom_inout.c
@@ -45,6 +45,7 @@
 #include "funcapi.h"
 
 #include "liblwgeom.h"
+#include "lwgeom_export.h"
 #include "lwgeom_pg.h"
 #include "geography.h" /* for lwgeom_valid_typmod */
 #include "lwgeom_transform.h"
@@ -70,7 +71,6 @@ Datum TWKBFromLWGEOM(PG_FUNCTION_ARGS);
 Datum TWKBFromLWGEOMArray(PG_FUNCTION_ARGS);
 Datum LWGEOMFromTWKB(PG_FUNCTION_ARGS);
 
-
 /*
  * LWGEOM_in(cstring)
  * format is '[SRID=#;]wkt|wkb'
@@ -78,6 +78,7 @@ Datum LWGEOMFromTWKB(PG_FUNCTION_ARGS);
  *  LWGEOM_in( 'POINT(0 0)')            --> assumes SRID=SRID_UNKNOWN
  *  LWGEOM_in( 'SRID=99;0101000000000000000000F03F000000000000004')
  *  LWGEOM_in( '0101000000000000000000F03F000000000000004')
+ *  LWGEOM_in( '{"type":"Point","coordinates":[1,1]}')
  *  returns a GSERIALIZED object
  */
 PG_FUNCTION_INFO_V1(LWGEOM_in);
@@ -140,6 +141,19 @@ Datum LWGEOM_in(PG_FUNCTION_ARGS)
 		ret = geometry_serialize(lwgeom);
 		lwgeom_free(lwgeom);
 	}
+	else if (str[0] == '{')
+	{
+		char *srs = NULL;
+		lwgeom = lwgeom_from_geojson(str, &srs);
+		if (srs)
+		{
+			srid = getSRIDbySRS(srs);
+			lwfree(srs);
+			lwgeom_set_srid(lwgeom, srid);
+		}
+		ret = geometry_serialize(lwgeom);
+		lwgeom_free(lwgeom);
+	}
 	/* WKT then. */
 	else
 	{
diff --git a/regress/core/in_geojson.sql b/regress/core/in_geojson.sql
index df6b7d6..cc4a34c 100644
--- a/regress/core/in_geojson.sql
+++ b/regress/core/in_geojson.sql
@@ -55,3 +55,7 @@ SELECT '#4470.a', ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":
 SELECT '#4470.b', ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[],[0,0]]}'));
 SELECT '#4470.c', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[0,0]],[]]]}'));
 SELECT '#4470.d', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[],[0,0]]]}'));
+
+-- ::geometry cast
+SELECT 'cast1', ST_AsEWKT('{"type":"Point","coordinates":[1,1]}'::geometry);
+SELECT 'cast2', ST_AsEWKT(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1 1)'::geometry)::geometry);
diff --git a/regress/core/in_geojson_expected b/regress/core/in_geojson_expected
index 0a0e7de..e3c4eec 100644
--- a/regress/core/in_geojson_expected
+++ b/regress/core/in_geojson_expected
@@ -36,3 +36,5 @@ ERROR:  The 'coordinates' in GeoJSON are not sufficiently nested
 #4470.b|POLYGON EMPTY
 #4470.c|MULTIPOLYGON(((0 0)))
 #4470.d|MULTIPOLYGON EMPTY
+cast1|POINT(1 1)
+cast2|SRID=3005;MULTIPOINT(1 1,1 1)

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

Summary of changes:
 NEWS                             |  6 +++---
 postgis/lwgeom_inout.c           | 16 +++++++++++++++-
 regress/core/in_geojson.sql      |  4 ++++
 regress/core/in_geojson_expected |  2 ++
 4 files changed, 24 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list