[postgis-users] 3d box intersection queries

Paragon Corporation lr at pcorp.us
Sun Apr 17 12:20:50 PDT 2011


Matt,

Unfortunately there isn't at the moment a way to convert the box3d to a 3D
box.  Though would be nice if we at least allowed that cast to happen.
Might happen before PostGIS 2.0 is out
Since it has been at the back of my mind and strk's at least.

As far as the box3d goes,  there is supposed to be a box3d &&& box3d
operator which unfortunately isn't exposed yet (as far as I can tell) that
will allow you to do this.

Paul Ramsey who is working on it -- is a bit preoccupied at the moment with
politics.  He should be hopefully back to normal in the next week or so and
can finish where he left
off.

He might pay more attention to you if you  tweet him and phrase your
question in the context of Canadian politics -  http://twitter.com/pwramsey
:)


Thanks,
Regina
http://www.postgis.us


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Matthias
Sent: Sunday, April 17, 2011 7:23 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] 3d box intersection queries

Am 16.04.2011, 06:12 Uhr, schrieb Matthias <nitro at dr-code.org>:

> Hello,
>
> My entities are defined as boxes in 3d. Now I want to be able to query 
> all entities within a certain (bigger) 3d bounding box. What's the 
> recommended way to do this with PostGIS? Usually I'd just use an 
> r-tree for this task, but I want to use it within the context of a
database.
>
> For a start I downloaded the postgis 2.0 windows experimental binaries 
> and performed a query like
>
> SELECT ST_3DIntersects(box1, box2) FROM (SELECT
>
> ST_GeomFromEWKT('POLYHEDRALSURFACE(
> ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 
> 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
> ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)), ((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 
> 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )') AS box1,
>
> ST_GeomFromEWKT('POLYHEDRALSURFACE(
> ((2 0 0, 2 0 1, 2 1 1, 2 1 0, 2 0 0)),
> ((2 0 0, 2 1 0, 3 1 0, 3 0 0, 2 0 0)),
> ((2 0 0, 3 0 0, 3 0 1, 2 0 1, 2 0 0)),
> ((3 1 0, 3 1 1, 3 0 1, 3 0 0, 3 1 0)),
> ((2 1 0, 2 1 1, 3 1 1, 3 1 0, 2 1 0)),
> ((2 0 1, 3 0 1, 3 1 1, 2 1 1, 2 0 1)) )') AS box2
>
> ) as foo;
>
> which test if two cubes intersect.
>
> Now the polyhedrastuff looks a bit like overkill for simple 3d boxes. 
> Is there a better/faster/memory saving way to do this?

As a followup, I found the box3d type. However, this query

SELECT ST_3DIntersects('BOX3D(0 0 0, 1 1 1)'::box3d, 'BOX3D(0 0 2, 1 1
3)'::box3d)

returns "true" while the result should really be false. I suspect the box3d
is implicitly converted to a 2d polygon and then the intersection test is
performed. This way it will return "true".

Any idea how to do a simple 3d bounding box intersection test?

-Matthias
_______________________________________________
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