[postgis-users] Re: Question.
Kevin Neufeld
kneufeld at refractions.net
Thu Oct 30 12:07:32 PDT 2008
Hi ihab,
Unless you write some kind of custom plpgsql function to compute whether
a line intersects your custom polygons, this is not yet possible with
the current PostGIS functions. (I assume your "extruded polygons in 3D"
are a simple 2D polygon with some height attribute, so the z values are
all the same).
If you are cleaver enough to write such a function (and I encourage you
to try), you could use the cube module to quickly winnow your candidate
set down in the same way the && does in a normal spatial query.
Cheers,
Kevin
eehab hamzeh wrote:
> 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 GI
> ST (
> 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 Get it now!
> <http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline>*
More information about the postgis-users
mailing list