[postgis-users] Re: Question.

Paragon Corporation lr at pcorp.us
Thu Oct 30 13:05:59 PDT 2008


Ihab,

So are you trying to deal with 3d lines intersecting 3d buildings (e.g. 2D
extruded with z value as Kevin mentioned) or are you dealing with 3d points
intersecting the 3D buildings or are your 3d objects ref objects not
parallel to the ground.

Anyrate if you can provide the ST_AsEWKT outputs of some of these
geometries, that would help.

For the case of 3D point intersecting a building where the footprint is on
the ground, you can use the relatively simple solution that

ST_Intersects(buidling_footPrint, point) AND ST_Z(point) Between 0 and
heightOfbuilding

For line_strings you may want to look at the Linear Referencing functions
which many seem to support 3D and may be repurposed for something like this.

I will be tackling a similar problem soon except in my case, I can't count
on any objects being parallel to the ground since it will be modelling a
control lab where the equipment is in all sorts of orientations and
elevations.  First I have to wrap my head around all this Web3D/X3d (AKA
VRML revisited) stuff which seems to be changing seemingly daily.

Hope that helps,
Regina 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Kevin
Neufeld
Sent: Thursday, October 30, 2008 3:08 PM
To: eehab hamzeh
Cc: postgis-users at postgis.refractions.net
Subject: [postgis-users] Re: Question.

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&s
> ource=wlmailtagline>*
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-users mailing list