[postgis-tickets] r15445 - ST_AsX3D handle empty geometries
Regina Obe
lr at pcorp.us
Thu Jun 22 23:15:04 PDT 2017
Author: robe
Date: 2017-06-22 23:15:04 -0700 (Thu, 22 Jun 2017)
New Revision: 15445
Modified:
branches/2.3/NEWS
branches/2.3/liblwgeom/lwout_x3d.c
branches/2.3/regress/tickets.sql
branches/2.3/regress/tickets_expected
Log:
ST_AsX3D handle empty geometries
Closes #3704 for PostGIS 2.3.3
Modified: branches/2.3/NEWS
===================================================================
--- branches/2.3/NEWS 2017-06-23 06:00:59 UTC (rev 15444)
+++ branches/2.3/NEWS 2017-06-23 06:15:04 UTC (rev 15445)
@@ -15,6 +15,7 @@
(Shane StClair of Axiom Data Science)
- #3682, Strange fieldlength in result of pgsql2shp
- #3701, Escape double quotes issue in pgsql2shp
+ - #3704, ST_AsX3D crashes on empty geometry
PostGIS 2.3.2
Modified: branches/2.3/liblwgeom/lwout_x3d.c
===================================================================
--- branches/2.3/liblwgeom/lwout_x3d.c 2017-06-23 06:00:59 UTC (rev 15444)
+++ branches/2.3/liblwgeom/lwout_x3d.c 2017-06-23 06:15:04 UTC (rev 15445)
@@ -61,6 +61,15 @@
{
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 @@
size_t defidlen = strlen(defid);
size = pointArray_X3Dsize(line->points, precision)*2;
-
+
if ( X3D_USE_GEOCOORDS(opts) ) {
size += (
sizeof("<LineSet vertexCount=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' /></LineSet>") + defidlen
@@ -394,8 +403,8 @@
size = sizeof("<PointSet><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' /></PointSet>");
else
size = sizeof("<PointSet><Coordinate point='' /></PointSet>") + defidlen;
-
+
/* if ( srs ) size += strlen(srs) + sizeof(" srsName=.."); */
for (i=0; i<col->ngeoms; i++)
@@ -525,8 +534,8 @@
if ( X3D_USE_GEOCOORDS(opts) ) size = sizeof("<IndexedFaceSet convex='false' coordIndex=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' />") + defidlen;
else size = sizeof("<IndexedFaceSet convex='false' coordIndex=''><Coordinate point='' />") + defidlen;
-
+
for (i=0; i<psur->ngeoms; i++)
{
size += asx3d3_poly_size(psur->geoms[i], 0, precision, opts, defid)*5; /** need to make space for coordIndex values too including -1 separating each poly**/
@@ -658,7 +667,7 @@
if ( X3D_USE_GEOCOORDS(opts) ) ptr += sprintf(ptr, "'><GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ( (opts & LW_X3D_FLIP_XY) ? "latitude_first" : "longitude_first") );
else ptr += sprintf(ptr, "'><Coordinate point='");
-
+
for (i=0; i<tin->ngeoms; i++)
{
ptr += asx3d3_triangle_buf(tin->geoms[i], 0, ptr, precision,
@@ -781,12 +790,12 @@
else if ( subgeom->type == TINTYPE )
{
ptr += asx3d3_tin_buf((LWTIN*)subgeom, srs, ptr, precision, opts, defid);
-
+
}
else if ( subgeom->type == POLYHEDRALSURFACETYPE )
{
ptr += asx3d3_psurface_buf((LWPSURFACE*)subgeom, srs, ptr, precision, opts, defid);
-
+
}
else if ( lwgeom_is_collection(subgeom) )
{
@@ -862,7 +871,7 @@
if ( i )
ptr += sprintf(ptr, " ");
-
+
if ( ( opts & LW_X3D_FLIP_XY) )
ptr += sprintf(ptr, "%s %s", y, x);
else
Modified: branches/2.3/regress/tickets.sql
===================================================================
--- branches/2.3/regress/tickets.sql 2017-06-23 06:00:59 UTC (rev 15444)
+++ branches/2.3/regress/tickets.sql 2017-06-23 06:15:04 UTC (rev 15445)
@@ -1012,5 +1012,8 @@
SELECT '#3627a', ST_AsEncodedPolyline('SRID=4326;LINESTRING(-0.250691 49.283048,-0.250633 49.283376,-0.250502 49.283972,-0.251245 49.284028,-0.251938 49.284232,-0.251938 49.2842)', 6);
SELECT '#3627b', ST_Equals(geom, ST_LineFromEncodedPolyline(ST_AsEncodedPolyline(geom, 7), 7)) FROM (VALUES ('SRID=4326;LINESTRING (0 0, 1 1)')) AS v (geom);
+-- #3704
+SELECT '#3704', ST_AsX3D('LINESTRING EMPTY') = '';
+
-- Clean up
DELETE FROM spatial_ref_sys;
Modified: branches/2.3/regress/tickets_expected
===================================================================
--- branches/2.3/regress/tickets_expected 2017-06-23 06:00:59 UTC (rev 15444)
+++ branches/2.3/regress/tickets_expected 2017-06-23 06:15:04 UTC (rev 15445)
@@ -301,3 +301,4 @@
#3620b|POINT(2 8)
#3627a|o}~~|AdshNoSsBgd at eGoBlm@wKhj@~@?
#3627b|t
+#3704|t
More information about the postgis-tickets
mailing list