[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha2-22-gf0822be

git at osgeo.org git at osgeo.org
Wed Jul 29 05:14:08 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  f0822be70d65421df09f74cbc3d4cb54aac38985 (commit)
       via  6a0627cdef29d5fc590fe6bbb73b92fd1a82da96 (commit)
      from  90a15b199ff55e946281c7200e0930e28dfdd585 (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 f0822be70d65421df09f74cbc3d4cb54aac38985
Author: Raúl Marín <git at rmr.ninja>
Date:   Tue Jul 28 18:07:19 2020 +0200

    Add precision parameter to ST_AsEWKT
    
    Closes #4698
    Closes https://github.com/postgis/postgis/pull/575

diff --git a/NEWS b/NEWS
index 4cfdb46..319f74b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,7 @@ PostGIS 3.1.0beta1
 Only tickets not included in 3.1.0alpha2
 
 * New features *
-  -
+  - #4698, Add a precision parameter to ST_AsEWKT (Raúl Marín)
 
 * Enhancements *
   - #4660, Changes in double / coordinate printing (Raúl Marín)
diff --git a/doc/reference_output.xml b/doc/reference_output.xml
index f64b992..b2dd96f 100644
--- a/doc/reference_output.xml
+++ b/doc/reference_output.xml
@@ -26,15 +26,26 @@
 			  </funcprototype>
 			  <funcprototype>
 				<funcdef>text <function>ST_AsEWKT</function></funcdef>
+				<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+				<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
+			  </funcprototype>
+			  <funcprototype>
+				<funcdef>text <function>ST_AsEWKT</function></funcdef>
 				<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
 			  </funcprototype>
+			  <funcprototype>
+				<funcdef>text <function>ST_AsEWKT</function></funcdef>
+				<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
+				<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
+			  </funcprototype>
 			</funcsynopsis>
 		  </refsynopsisdiv>
 
 		  <refsection>
 			<title>Description</title>
 
-			<para>Returns the Well-Known Text representation of the geometry prefixed with the SRID.</para>
+			<para>Returns the Well-Known Text representation of the geometry prefixed with the SRID. Optional argument may be used to reduce the maximum number
+			of decimal digits after floating point used in output (defaults to 15).</para>
 
 			<note>
 			  <para>The WKT spec does not include the SRID.  To get the OGC WKT format use ST_AsText.</para>
@@ -46,6 +57,7 @@
 			  <para>ST_AsEWKT is the reverse of <xref linkend="ST_GeomFromEWKT" />.  Use <xref linkend="ST_GeomFromEWKT" /> to convert to a postgis geometry from ST_AsEWKT representation.</para>
 			</note>
 			<para>Enhanced: 2.0.0 support for Geography, Polyhedral surfaces, Triangles and TIN was introduced.</para>
+            <para>Enhanced: 3.1.0 support for optional precision parameter.</para>
 			<para>&Z_support;</para>
 			<para>&curve_support;</para>
 			<para>&P_support;</para>
diff --git a/postgis/geography.sql.in b/postgis/geography.sql.in
index 6a2d3d9..7d7b6da 100644
--- a/postgis/geography.sql.in
+++ b/postgis/geography.sql.in
@@ -710,6 +710,12 @@ CREATE OR REPLACE FUNCTION ST_AsEWKT(geography)
 	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
 	_COST_MEDIUM;
 
+CREATE OR REPLACE FUNCTION ST_AsEWKT(geography, int4)
+	RETURNS TEXT
+	AS 'MODULE_PATHNAME','LWGEOM_asEWKT'
+	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
+	_COST_MEDIUM;
+
 -- Availability: 2.0.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
 CREATE OR REPLACE FUNCTION ST_AsEWKT(text)
 	RETURNS text AS
diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c
index e6b76d8..1ed7942 100644
--- a/postgis/lwgeom_functions_basic.c
+++ b/postgis/lwgeom_functions_basic.c
@@ -2384,8 +2384,11 @@ Datum LWGEOM_asEWKT(PG_FUNCTION_ARGS)
 	GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
 	LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
 
-	POSTGIS_DEBUG(2, "LWGEOM_asEWKT called.");
-	PG_RETURN_TEXT_P(lwgeom_to_wkt_varlena(lwgeom, WKT_EXTENDED, OUT_DEFAULT_DECIMAL_DIGITS));
+	int precision = OUT_DEFAULT_DECIMAL_DIGITS;
+	if (PG_NARGS() > 1)
+		precision = PG_GETARG_INT32(1);
+
+	PG_RETURN_TEXT_P(lwgeom_to_wkt_varlena(lwgeom, WKT_EXTENDED, precision));
 }
 
 /**
diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in
index 0dfa55e..8fcd15f 100644
--- a/postgis/postgis.sql.in
+++ b/postgis/postgis.sql.in
@@ -1549,6 +1549,13 @@ CREATE OR REPLACE FUNCTION ST_AsEWKT(geometry)
 	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
 	_COST_MEDIUM;
 
+-- Availability: 3.1.0
+CREATE OR REPLACE FUNCTION ST_AsEWKT(geometry, int4)
+	RETURNS TEXT
+	AS 'MODULE_PATHNAME','LWGEOM_asEWKT'
+	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
+	_COST_MEDIUM;
+
 -- Availability: 2.2.0
 CREATE OR REPLACE FUNCTION ST_AsTWKB(geom geometry, prec int4 default NULL, prec_z int4 default NULL, prec_m int4 default NULL, with_sizes boolean default NULL, with_boxes boolean default NULL)
 	RETURNS bytea
diff --git a/regress/core/out_geometry.sql b/regress/core/out_geometry.sql
index fdc9a5c..b8f41b9 100644
--- a/regress/core/out_geometry.sql
+++ b/regress/core/out_geometry.sql
@@ -166,3 +166,10 @@ SELECT 'pgcast_06',ST_AsText('((0,0),(0,1),(1,1),(1,0))'::polygon::geometry);
 -- Precision
 SELECT 'text_precision_01', ST_AsText(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)'));
 SELECT 'text_precision_02', ST_AsText(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)'),2);
+
+--
+-- ST_AsEWKT
+--
+SELECT 'EWKT_' || i, ST_AsEWKT('SRID=4326;POINT(12345678.123456789 1)'::geometry, i)
+FROM generate_series(0, 20) AS t(i)
+ORDER BY i;
\ No newline at end of file
diff --git a/regress/core/out_geometry_expected b/regress/core/out_geometry_expected
index 4707206..13f0c88 100644
--- a/regress/core/out_geometry_expected
+++ b/regress/core/out_geometry_expected
@@ -90,3 +90,24 @@ pgcast_05|t
 pgcast_06|POLYGON((0 0,0 1,1 1,1 0,0 0))
 text_precision_01|POINT(111.1111111 1.1111111)
 text_precision_02|POINT(111.11 1.11)
+EWKT_0|SRID=4326;POINT(12345678 1)
+EWKT_1|SRID=4326;POINT(12345678.1 1)
+EWKT_2|SRID=4326;POINT(12345678.12 1)
+EWKT_3|SRID=4326;POINT(12345678.123 1)
+EWKT_4|SRID=4326;POINT(12345678.1235 1)
+EWKT_5|SRID=4326;POINT(12345678.12346 1)
+EWKT_6|SRID=4326;POINT(12345678.123457 1)
+EWKT_7|SRID=4326;POINT(12345678.1234568 1)
+EWKT_8|SRID=4326;POINT(12345678.12345679 1)
+EWKT_9|SRID=4326;POINT(12345678.12345679 1)
+EWKT_10|SRID=4326;POINT(12345678.12345679 1)
+EWKT_11|SRID=4326;POINT(12345678.12345679 1)
+EWKT_12|SRID=4326;POINT(12345678.12345679 1)
+EWKT_13|SRID=4326;POINT(12345678.12345679 1)
+EWKT_14|SRID=4326;POINT(12345678.12345679 1)
+EWKT_15|SRID=4326;POINT(12345678.12345679 1)
+EWKT_16|SRID=4326;POINT(12345678.12345679 1)
+EWKT_17|SRID=4326;POINT(12345678.12345679 1)
+EWKT_18|SRID=4326;POINT(12345678.12345679 1)
+EWKT_19|SRID=4326;POINT(12345678.12345679 1)
+EWKT_20|SRID=4326;POINT(12345678.12345679 1)

commit 6a0627cdef29d5fc590fe6bbb73b92fd1a82da96
Author: Raúl Marín <git at rmr.ninja>
Date:   Wed Jul 29 14:10:37 2020 +0200

    Adapt regress tests to match Windows output
    
    References #4660

diff --git a/regress/core/regress_buffer_params.sql b/regress/core/regress_buffer_params.sql
index a1bbe24..2e05a7f 100644
--- a/regress/core/regress_buffer_params.sql
+++ b/regress/core/regress_buffer_params.sql
@@ -5,8 +5,8 @@
 
 -- Ouput is snapped to grid to account for small floating numbers
 -- differences between architectures
-SELECT 'point quadsegs=2', ST_AsText(st_buffer('POINT(0 0)', 1, 'quad_segs=2'), 5);
-SELECT 'line quadsegs=2', ST_AsText(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2'), 5);
+SELECT 'point quadsegs=2', ST_AsText(st_buffer('POINT(0 0)', 1, 'quad_segs=2'), 4);
+SELECT 'line quadsegs=2', ST_AsText(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2'), 3);
 SELECT 'line quadsegs=2 endcap=flat', ST_AsText(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2 endcap=flat'), 5);
 SELECT 'line quadsegs=2 endcap=butt', ST_AsText(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2 endcap=butt'), 5);
 SELECT 'line quadsegs=2 endcap=square', ST_AsText(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2 endcap=square'), 5);
diff --git a/regress/core/regress_buffer_params_expected b/regress/core/regress_buffer_params_expected
index 27c1e9f..5eb856b 100644
--- a/regress/core/regress_buffer_params_expected
+++ b/regress/core/regress_buffer_params_expected
@@ -1,5 +1,5 @@
-point quadsegs=2|POLYGON((1 0,0.70711 -0.70711,1.61554e-15 -1,-0.70711 -0.70711,-1 -3.23109e-15,-0.70711 0.70711,-4.62459e-15 1,0.70711 0.70711,1 0))
-line quadsegs=2|POLYGON((10 2,11.41421 1.41421,12 0,11.41421 -1.41421,10 -2,0 -2,-1.41421 -1.41421,-2 2.44929e-16,-1.41421 1.41421,0 2,10 2))
+point quadsegs=2|POLYGON((1 0,0.7071 -0.7071,1.6155e-15 -1,-0.7071 -0.7071,-1 -3.2311e-15,-0.7071 0.7071,-4.6246e-15 1,0.7071 0.7071,1 0))
+line quadsegs=2|POLYGON((10 2,11.4142 1.4142,12 0,11.4142 -1.4142,10 -2,0 -2,-1.4142 -1.4142,-2 2.4493e-16,-1.4142 1.4142,0 2,10 2))
 line quadsegs=2 endcap=flat|POLYGON((10 2,10 -2,0 -2,0 2,10 2))
 line quadsegs=2 endcap=butt|POLYGON((10 2,10 -2,0 -2,0 2,10 2))
 line quadsegs=2 endcap=square|POLYGON((10 2,12 2,12 -2,0 -2,-2 -2,-2 2,10 2))
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index 61078b3..a635345 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -794,7 +794,7 @@ SELECT '#2420.2', ST_AsText(ST_LineToCurve('LINESTRING(0 0,10 0,10 10,0 10)'));
 
 SELECT '#2423', ST_AsText(ST_CurveToLine(ST_LineToCurve(
   ST_Intersection(ST_Buffer(ST_Point(0,0),10),ST_MakeEnvelope(-10,0,10,10))
-), 4), 4);
+), 4), 3);
 
 SELECT '#2424', ST_AsText(ST_SnapToGrid(ST_CurveToLine(
   'MULTICURVE(COMPOUNDCURVE((0 0, 10 0),CIRCULARSTRING(10 0, 20 1, 30 10)))',
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index 917d374..0a60194 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -252,7 +252,7 @@ ERROR:  invalid GML representation
 #2412|LINESTRING(0 0,10 0,20 0)
 #2420.1|LINESTRING(0 0,10 0,10 10,0 10,0 0)
 #2420.2|LINESTRING(0 0,10 0,10 10,0 10)
-#2423|POLYGON((-10 0,-9.2388 3.8268,-7.0711 7.0711,-3.8268 9.2388,1.7157e-15 10,3.8268 9.2388,7.0711 7.0711,9.2388 3.8268,10 0,-10 0))
+#2423|POLYGON((-10 0,-9.239 3.827,-7.071 7.071,-3.827 9.239,1.716e-15 10,3.827 9.239,7.071 7.071,9.239 3.827,10 0,-10 0))
 #2424|MULTILINESTRING((0 0,10 0,24 3,30 10))
 #2427|POINT(-1 0)
 #2168|5340.76237395|5340.76237395|0

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

Summary of changes:
 NEWS                                        |  2 +-
 doc/reference_output.xml                    | 14 +++++++++++++-
 postgis/geography.sql.in                    |  6 ++++++
 postgis/lwgeom_functions_basic.c            |  7 +++++--
 postgis/postgis.sql.in                      |  7 +++++++
 regress/core/out_geometry.sql               |  7 +++++++
 regress/core/out_geometry_expected          | 21 +++++++++++++++++++++
 regress/core/regress_buffer_params.sql      |  4 ++--
 regress/core/regress_buffer_params_expected |  4 ++--
 regress/core/tickets.sql                    |  2 +-
 regress/core/tickets_expected               |  2 +-
 11 files changed, 66 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list