(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
"33.6673 38.6972,33.6626 38.6871)",
5,
"k~fkFsvolEbe@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
{
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);