[postgis-users] using && operator
Aman Verma
aman.verma at mcgill.ca
Fri Aug 20 07:25:56 PDT 2010
Hi,
It looks like you're having a little bit of trouble with the SQL. That is understandable though, your problem is a little tricky, because it requires you to nest a query.
You should first note that it is not possible to have two FROM statements in a single query. Start by breaking down the problem into individual parts:
1) You need to collect both geometry columns each into a single collection. You can do this with two separate queries:
select st_collect(pkt) as first_set from pktbsp1;
select st_collect(pkt) as second_set from pktbsp2;
2) Now, you need to find a way to have the result of both these tables in a single place. This is done by nesting the two above queries into another query.
select x.first_set, y.second_set from
(select st_collect(pkt) as first_set from pktbsp1) x, -- I could have used JOIN instead of a comma.
(select st_collect(pkt) as second_set from pktbsp2) y;
If you're having trouble figuring out how the query nesting works, I suggest brushing up your SQL at sqlzoo.net.
3) Now, you can compare these two geometries. So the full query is:
select x.first_set && y.second_set from -- Note that st_intersects (x.first_set,y.second_set) would be fine too
(select st_collect(pkt) as first_set from pktbsp1) x,
(select st_collect(pkt) as second_set from pktbsp2) y;
That will return a single row with a single column: t or f.
Hope that helps,
aman
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Jan Saalbach
Sent: August 20, 2010 10:02 AM
To: PostGis Users List
Subject: [postgis-users] using && operator
Hi List,
how do I check if two 3d-point sets overlap? I see the && operator
should be able to compare the bounding boxes, but how do I do it? I
can not get the && or ST_Intersects function to work. Here is what I
am trying to do:
SELECT ST_Collect(pkt) FROM pktbsp && ST_Collect(pkt) FROM pktbsp2;
pkt are GeometryColumns filled with 3dpoints. pktbsp and pktbsp2 are
the respective tables.
How can I check this?
Reagrds,
Jan
_______________________________________________
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