Changeset 15445


Ignore:
Timestamp:
Jun 22, 2017, 11:15:04 PM (6 years ago)
Author:
robe
Message:

ST_AsX3D handle empty geometries
Closes #3704 for PostGIS 2.3.3

Location:
branches/2.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/NEWS

    r15442 r15445  
    1616  - #3682, Strange fieldlength in result of pgsql2shp
    1717  - #3701, Escape double quotes issue in pgsql2shp
     18  - #3704, ST_AsX3D crashes on empty geometry
    1819
    1920
  • branches/2.3/liblwgeom/lwout_x3d.c

    r14869 r15445  
    6262        int type = geom->type;
    6363
     64        /* Empty string for empties */
     65        if( lwgeom_is_empty(geom) )
     66        {
     67                char *ret = NULL;
     68                ret = lwalloc(1);
     69                ret[0] = '\0';
     70                return ret;
     71        }
     72
    6473        switch (type)
    6574        {
     
    157166
    158167        size = pointArray_X3Dsize(line->points, precision)*2;
    159        
     168
    160169        if ( X3D_USE_GEOCOORDS(opts) ) {
    161170                        size += (
     
    395404        else
    396405                size = sizeof("<PointSet><Coordinate point='' /></PointSet>") + defidlen;
    397        
     406
    398407
    399408        /* if ( srs ) size += strlen(srs) + sizeof(" srsName=.."); */
     
    526535        if ( X3D_USE_GEOCOORDS(opts) ) size = sizeof("<IndexedFaceSet convex='false' coordIndex=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' />") + defidlen;
    527536        else size = sizeof("<IndexedFaceSet convex='false' coordIndex=''><Coordinate point='' />") + defidlen;
    528        
     537
    529538
    530539        for (i=0; i<psur->ngeoms; i++)
     
    659668        if ( X3D_USE_GEOCOORDS(opts) ) ptr += sprintf(ptr, "'><GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ( (opts & LW_X3D_FLIP_XY) ? "latitude_first" : "longitude_first") );
    660669        else ptr += sprintf(ptr, "'><Coordinate point='");
    661        
     670
    662671        for (i=0; i<tin->ngeoms; i++)
    663672        {
     
    782791                {
    783792                        ptr += asx3d3_tin_buf((LWTIN*)subgeom, srs, ptr, precision, opts,  defid);
    784                        
     793
    785794                }
    786795                else if ( subgeom->type == POLYHEDRALSURFACETYPE )
    787796                {
    788797                        ptr += asx3d3_psurface_buf((LWPSURFACE*)subgeom, srs, ptr, precision, opts,  defid);
    789                        
     798
    790799                }
    791800                else if ( lwgeom_is_collection(subgeom) )
     
    863872                                if ( i )
    864873                                        ptr += sprintf(ptr, " ");
    865                                        
     874
    866875                                if ( ( opts & LW_X3D_FLIP_XY) )
    867876                                        ptr += sprintf(ptr, "%s %s", y, x);
  • branches/2.3/regress/tickets.sql

    r15138 r15445  
    10131013SELECT '#3627b', ST_Equals(geom, ST_LineFromEncodedPolyline(ST_AsEncodedPolyline(geom, 7), 7)) FROM (VALUES ('SRID=4326;LINESTRING (0 0, 1 1)')) AS v (geom);
    10141014
     1015-- #3704
     1016SELECT '#3704', ST_AsX3D('LINESTRING EMPTY') = '';
     1017
    10151018-- Clean up
    10161019DELETE FROM spatial_ref_sys;
  • branches/2.3/regress/tickets_expected

    r15138 r15445  
    302302#3627a|o}~~|AdshNoSsBgd@eGoBlm@wKhj@~@?
    303303#3627b|t
     304#3704|t
Note: See TracChangeset for help on using the changeset viewer.