[postgis-users] Sql 3Dbox
Kevin Neufeld
kneufeld at refractions.net
Thu Oct 16 09:35:13 PDT 2008
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
>
>
More information about the postgis-users
mailing list