From 4a4af48bcc9a8bc49db762fd6c87cdb76cc1c3c5 Mon Sep 17 00:00:00 2001 From: Regina Obe Date: Fri, 23 Jun 2017 06:00:59 +0000 Subject: [PATCH] ST_AsX3D handle empty geometries References #3704 for PostGIS 2.4 (trunk) git-svn-id: http://svn.osgeo.org/postgis/trunk@15444 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwout_x3d.c | 23 ++++++++++++++++------- regress/tickets.sql | 7 +++++-- regress/tickets_expected | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/liblwgeom/lwout_x3d.c b/liblwgeom/lwout_x3d.c index e6058e048..5dd2a5181 100644 --- a/liblwgeom/lwout_x3d.c +++ b/liblwgeom/lwout_x3d.c @@ -61,6 +61,15 @@ lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const cha { int type = geom->type; + /* Empty string for empties */ + if( lwgeom_is_empty(geom) ) + { + char *ret = NULL; + ret = lwalloc(1); + ret[0] = '\0'; + return ret; + } + switch (type) { case POINTTYPE: @@ -156,7 +165,7 @@ asx3d3_line_size(const LWLINE *line, char *srs, int precision, int opts, const c size_t defidlen = strlen(defid); size = pointArray_X3Dsize(line->points, precision)*2; - + if ( X3D_USE_GEOCOORDS(opts) ) { size += ( sizeof("") + defidlen @@ -394,7 +403,7 @@ asx3d3_multi_size(const LWCOLLECTION *col, char *srs, int precision, int opts, c size = sizeof(""); else size = sizeof("") + defidlen; - + /* if ( srs ) size += strlen(srs) + sizeof(" srsName=.."); */ @@ -525,7 +534,7 @@ asx3d3_psurface_size(const LWPSURFACE *psur, char *srs, int precision, int opts, if ( X3D_USE_GEOCOORDS(opts) ) size = sizeof("") + defidlen; else size = sizeof("") + defidlen; - + for (i=0; ingeoms; i++) { @@ -658,7 +667,7 @@ asx3d3_tin_buf(const LWTIN *tin, char *srs, char *output, int precision, int opt if ( X3D_USE_GEOCOORDS(opts) ) ptr += sprintf(ptr, "'>