[postgis-users] Question.

eehab hamzeh eehab40 at hotmail.com
Thu Oct 30 11:40:36 PDT 2008


Hello Kevin
below is your replay to a question i post before 12 days. i kindly asked you to look to 
what it again since my building are not 3D boxes they are not squares or rectangles, they are polygons has z values
 i need to find the lines that intersect these extruded polygons in 3D.
 
Thanks 
ihab 


Indexes in PostGIS are still only 2D.  Hopefully 3D indexes will be 
added sometime in the future, but in the meantime, you can perform your 
3D query using the cube module.
 
http://www.postgresql.org/docs/8.3/static/cube.html
 
-- Sample 3D box table
CREATE TABLE boxes (box box3d);
INSERT INTO boxes SELECT 'BOX3D(0 0 0,2 2 2)'::box3d;
INSERT INTO boxes SELECT 'BOX3D(0 4 0,2 6 2)'::box3d;
 
 
-- Sample 3D index
CREATE INDEX boxes_box_cube_idx ON boxes USING GIST (
   cube(
     cube(
       cube(ST_XMin(box), ST_XMax(box)),
       ST_YMin(box),
       ST_YMax(box)
     ),
     ST_ZMin(box),
     ST_ZMax(box)
   )
);
 
 
-- Sample 3D intersect query
SELECT box
FROM boxes
WHERE '(-1,1,1),(3,1,1)'::cube &&
   cube(
     cube(
       cube(ST_XMin(box), ST_XMax(box)),
       ST_YMin(box),
       ST_YMax(box)
     ),
     ST_ZMin(box),
     ST_ZMax(box)
   );
 
 
-- Yields
         box
--------------------
  BOX3D(0 0 0,2 2 2)
(1 row)
 
 
 
Cheers,
Kevin
 
eehab hamzeh wrote:
> Hello,
> 
> 
> I try to use the && operator to select the boxes that intersect one line 
> in 3d .. i need help to develop the Sql statement,
> 
> Select AsText(line_geom) as geom from line where line_geom && 
> geomFromText(Select astext(the_geom) from boxex)',-1);
> 
> attached is a graph shows how the query result should looks i need just 
> the red box to be seleced since the line intersect only the red box and 
> not the another box which is lower than the line height.
> 
> Thanks
> 
> 
_________________________________________________________________
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081030/30884e29/attachment.html>


More information about the postgis-users mailing list