[postgis-devel] Conversion from box3d to box2d changes bounds

Charlie Savage cfis at savagexi.com
Sat Sep 22 15:58:46 PDT 2007

More of fixing up the envelope function.  It turns out the approach 
Martin suggested for Envelope (take the bounds of the geometry, then use 
that to figure out the return geometry type) doesn't actually work in 


select astext(envelope('POINT(-104.967648983002 

"POLYGON((-104.967651367188 39.7123031616211,-104.967651367188 
39.7123069763184,-104.967643737793 39.7123069763184,-104.967643737793 
39.7123031616211,-104.967651367188 39.7123031616211))"

It should be a point.  A bit of digging shows why.


select box3d('POINT(-104.967648983002 39.7123038862956)'::geometry)

"BOX3D(-104.967648983002 39.7123038862956 0,-104.967648983002 
39.7123038862956 0)"

This is ok.  But this is not:

select box2d('POINT(-104.967648983002 39.7123038862956)'::geometry)

"BOX(-104.967651367188 39.7123031616211,-104.967643737793 39.7123069763184)"

Notice that the box2d is no longer a point - and that the bounds have 
changed?  Its because the this function:

box3d_to_box2df(BOX3D *box)
	result->xmin = nextDown_f(box->xmin);
	result->xmax = nextUp_f(box->xmax);

Notice it *intentionally* changes the bounding box.  I assume there is a 
good reason for this, but curious what it is.

If this is correct, then it means my patch to Envelope needs to change 
to recognize if a geometry is a point (versus just checking the bounding 
box as it does now).



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20070922/3edaa412/attachment.bin>

More information about the postgis-devel mailing list