[postgis-tickets] r16263 - Encoded Polyline of EMPTY
Darafei
komzpa at gmail.com
Fri Jan 12 12:18:40 PST 2018
Author: komzpa
Date: 2018-01-12 00:18:39 -0800 (Fri, 12 Jan 2018)
New Revision: 16263
Modified:
trunk/NEWS
trunk/liblwgeom/cunit/cu_out_encoded_polyline.c
trunk/liblwgeom/lwout_encoded_polyline.c
Log:
Encoded Polyline of EMPTY
Closes #3982
Closes https://github.com/postgis/postgis/pull/189
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2018-01-11 22:09:35 UTC (rev 16262)
+++ trunk/NEWS 2018-01-12 08:18:39 UTC (rev 16263)
@@ -33,6 +33,8 @@
(Darafei Praliaskouski)
- #3971, ST_ClusterKMeans now uses better initial seed (Darafei Praliaskouski)
- #3977, ST_ClusterKMeans is now faster and simpler (Darafei Praliaskouski)
+ - #3982, ST_AsEncodedPolyline supports LINESTRING EMPTY and MULTIPOINT EMPTY
+ (Darafei Praliaskouski)
PostGIS 2.4.0
2017/09/30
Modified: trunk/liblwgeom/cunit/cu_out_encoded_polyline.c
===================================================================
--- trunk/liblwgeom/cunit/cu_out_encoded_polyline.c 2018-01-11 22:09:35 UTC (rev 16262)
+++ trunk/liblwgeom/cunit/cu_out_encoded_polyline.c 2018-01-12 08:18:39 UTC (rev 16263)
@@ -46,17 +46,18 @@
"33.6673 38.6972,33.6626 38.6871)",
5,
"k~fkFsvolEbe at bVvVzJb~@j\\");
- return;
/* Linestring */
do_encoded_polyline_test(
"LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)",
5,
"_p~iF~ps|U_ulLnnqC_mqNvxq`@");
+ do_encoded_polyline_test("LINESTRING EMPTY", 5, "");
/* MultiPoint */
do_encoded_polyline_test(
"MULTIPOINT(-120.2 38.5,-120.95 40.7)", 5, "_p~iF~ps|U_ulLnnqC");
+ do_encoded_polyline_test("MULTIPOINT EMPTY", 5, "");
}
static void
Modified: trunk/liblwgeom/lwout_encoded_polyline.c
===================================================================
--- trunk/liblwgeom/lwout_encoded_polyline.c 2018-01-11 22:09:35 UTC (rev 16262)
+++ trunk/liblwgeom/lwout_encoded_polyline.c 2018-01-12 08:18:39 UTC (rev 16263)
@@ -69,18 +69,27 @@
{
int i;
const POINT2D* prevPoint;
- int* delta = lwalloc(2 * sizeof(int) * pa->npoints);
+ int* delta;
char* encoded_polyline = NULL;
stringbuffer_t* sb;
double scale = pow(10, precision);
+ /* Empty input is empty string */
+ if (pa->npoints == 0) {
+ encoded_polyline = lwalloc(1 * sizeof(char));
+ encoded_polyline[0] = 0;
+ return encoded_polyline;
+ }
+
+ delta = lwalloc(2 * sizeof(int) * pa->npoints);
+
/* Take the double value and multiply it by 1x10^precision, rounding the
* result */
prevPoint = getPoint2d_cp(pa, 0);
delta[0] = round(prevPoint->y * scale);
delta[1] = round(prevPoint->x * scale);
- /* points only include the offset from the previous point */
+ /* Points only include the offset from the previous point */
for (i = 1; i < pa->npoints; i++)
{
const POINT2D* point = getPoint2d_cp(pa, i);
More information about the postgis-tickets
mailing list