[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-431-ga9382ae
git at osgeo.org
git at osgeo.org
Wed Aug 25 10:56:23 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, master has been updated
via a9382ae7fdbcbe9666cad0c0303991f3049865b5 (commit)
from d02637045e019c810cf0aeac3d95f3d255eff05f (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 a9382ae7fdbcbe9666cad0c0303991f3049865b5
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Aug 25 10:56:07 2021 -0700
Include srs in GeoJSON where it exists in spatial_ref_sys, closes #4799
diff --git a/NEWS b/NEWS
index d54da55..4b3c98b 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,7 @@ PostGIS 3.2.0
(Jan Katins of Aiven, Regina Obe)
- #4975, PostGIS upgrade change to not use temp tables (Jan Katins of Aiven)
- #4981, ST_StartPoint support any geometry (Aliaksandr Kalenik)
+ - #4799, Include srs in GeoJSON where it exists in spatial_ref_sys.
* New features*
diff --git a/postgis/lwgeom_export.c b/postgis/lwgeom_export.c
index 82fa86a..4d09512 100644
--- a/postgis/lwgeom_export.c
+++ b/postgis/lwgeom_export.c
@@ -267,7 +267,14 @@ Datum geometry_to_json(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
- lwvarlena_t *geojson = lwgeom_to_geojson(lwgeom, NULL, 15, 0);
+ const char *srs = NULL;
+ lwvarlena_t *geojson;
+ if (lwgeom->srid != SRID_UNKNOWN)
+ {
+ const int short_crs = LW_TRUE;
+ srs = GetSRSCacheBySRID(fcinfo, lwgeom->srid, short_crs);
+ }
+ geojson = lwgeom_to_geojson(lwgeom, srs, 15, 0);
lwgeom_free(lwgeom);
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_TEXT_P(geojson);
@@ -278,7 +285,14 @@ Datum geometry_to_jsonb(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
- lwvarlena_t *geojson = lwgeom_to_geojson(lwgeom, NULL, 15, 0);
+ const char *srs = NULL;
+ lwvarlena_t *geojson;
+ if (lwgeom->srid != SRID_UNKNOWN)
+ {
+ const int short_crs = LW_TRUE;
+ srs = GetSRSCacheBySRID(fcinfo, lwgeom->srid, short_crs);
+ }
+ geojson = lwgeom_to_geojson(lwgeom, srs, 15, 0);
lwgeom_free(lwgeom);
PG_RETURN_DATUM(DirectFunctionCall1(jsonb_in, PointerGetDatum(pstrdup(geojson->data))));
}
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index a84404f..72c597b 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1390,10 +1390,7 @@ SELECT '#4949', 'Arctic Stereographic forward', ST_AsEWKT(ST_SnapToGrid(ST_Trans
SELECT '#4949', 'Antarctic Stereographic forward', ST_AsEWKT(ST_SnapToGrid(ST_Transform(
'SRID=4326;POINT(-36.75 -54.25)'::geometry, 3031),0.1));
-
-- #4916, #4770, #4724, #4916, #4940
-
-
SELECT '#4770.a',
ST_Union(NULL::geometry) OVER (ORDER BY b)
FROM (VALUES ('A0006', 300),
@@ -1416,7 +1413,17 @@ WITH w AS (
('POINT(1 1)'::geometry, 'A0006', 302)) t(g, a, b)
)
SELECT '#4770.c', ST_AsText(g), s FROM w;
-------
+-- https://trac.osgeo.org/postgis/ticket/4799
+SELECT
+ '#4799', ST_AsGeoJSON(data.*, geom_column => 'geom2', maxdecimaldigits => 3)
+FROM
+ (SELECT
+ 1 AS id,
+ ST_SnapToGrid(ST_Transform(geom, 3035), 1) geom1,
+ ST_SnapToGrid(ST_Transform(geom, 25832), 1) geom2
+ FROM
+ ST_SetSRID(ST_MakePoint(7, 51), 4326) geom
+ ) data;
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index af581a8..2a3cb68 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -458,3 +458,4 @@ ERROR: LWGEOM_addpoint: Invalid offset
#4770.b|POINT(1 1)|302
#4770.c|POINT(0 0)|300
#4770.c|MULTIPOINT(0 0,1 1)|602
+#4799|{"type": "Feature", "geometry": {"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:25832"}},"coordinates":[359667,5651729]}, "properties": {"id": 1, "geom1": {"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:3035"}},"coordinates":[4110471,3103061]}}}
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
postgis/lwgeom_export.c | 18 ++++++++++++++++--
regress/core/tickets.sql | 15 +++++++++++----
regress/core/tickets_expected | 1 +
4 files changed, 29 insertions(+), 6 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list