[postgis-tickets] [PostGIS] #4020: Casting BOX3D to geometry invalid

PostGIS trac at osgeo.org
Mon Feb 19 06:06:07 PST 2018


#4020: Casting BOX3D to geometry invalid
---------------------+---------------------
 Reporter:  mat      |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:
Component:  postgis  |    Version:  2.4.x
 Keywords:           |
---------------------+---------------------
 When casting an actual BOX3D to geometry, the result is invalid.
 If it has a width of 0 in one ore more dimensions, it is fine.
 The problem is that the orientations of the top, front and left side of
 the polyhedral surface are wrong.

 Example:
 {{{
 > SELECT ST_AsText('BOX3D(1 2 3,4 5 6)'::BOX3D);
 POLYHEDRALSURFACE Z (((1 2 3,1 5 3,4 5 3,4 2 3,1 2 3)),((1 2 6,1 5 6,4 5
 6,4 2 6,1 2 6)),((1 2 3,1 5 3,1 5 6,1 2 6,1 2 3)),((4 2 3,4 5 3,4 5 6,4 2
 6,4 2 3)),((1 2 3,4 2 3,4 2 6,1 2 6,1 2 3)),((1 5 3,4 5 3,4 5 6,1 5 6,1 5
 3)))

 -- expected correct result:
 POLYHEDRALSURFACE Z (((1 2 3,1 5 3,4 5 3,4 2 3,1 2 3)),((1 2 6,4 2 6,4 5
 6,1 5 6,1 2 6)),((1 2 3,1 2 6,1 5 6,1 5 3,1 2 3)),((4 2 3,4 5 3,4 5 6,4 2
 6,4 2 3)),((1 2 3,4 2 3,4 2 6,1 2 6,1 2 3)),((1 5 3,1 5 6,4 5 6,4 5 3,1 5
 3)))
 }}}
 Notice the switched coordinates for the second (top), third (left) and
 sixth (front) polygon.

 This results e.g. in ST_Volume and ST_3DArea not accepting "true" BOX3Ds:
 {{{
 > SELECT ST_3DArea('BOX3D(1 2 3,1 5 6)'::BOX3D); -- works
 9
 > SELECT ST_3DArea('BOX3D(1 2 3,4 5 6)'::BOX3D); -- doesn't work
 SQL Error [XX000]: ERROR: Solid is invalid : PolyhedralSurface (shell) 0
 is invalid: not connected : SOLID((((1/1 2/1 3/1,1/1 5/1 3/1,4/1 5/1
 3/1,4/1 2/1 3/1,1/1 2/1 3/1)),((1/1 2/1 6/1,1/1 5/1 6/1,4/1 5/1 6/1,4/1
 2/1 6/1,1/1 2/1 6/1)),((1/1 2/1 3/1,1/1 5/1 3/1,1/1 5/1 6/1,1/1 2/1
 }}}

 I think the error is at {{{postgis/lwgeom_box3d.c}}}, lines 325-342.

 I'm using:
 {{{
 PostgreSQL 10.1, compiled by Visual C++ build 1800, 64-bit POSTGIS="2.4.3
 r16312" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d" SFCGAL="1.3.2"
 PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.3, released 2017/11/20"
 LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" RASTER
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4020>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list