[postgis-users] determining intersection count

Robert Burgholzer rburghol at chesapeakebay.net
Fri Jul 28 07:03:23 PDT 2006


Bart,
In your second query, you no longer screen on bouwvlak_id=10, and
therefore, not only are you getting a match for any object in table "bp"
which intersects the given text Geometry, but you are also getting a
match in the original table "b", presumably with all records in "b",
because you do not specify any criteria for "b". Are there 6 records in
table "b"? If so, then eliminate table "b" from your second query
entirely and you should get 2 records again.

r.b.

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Bart
van den Eijnden (OSGIS)
Sent: Friday, July 28, 2006 9:29 AM
To: PostGIS Users Discussion
Subject: [postgis-users] determining intersection count

Hi list,

I want to determine with how many geometries in a table a certain 
geometry (X) intersects. It works fine when I use:

SELECT count(*) FROM bestemmingsplannen.bouwvlakken AS b, 
bestemmingsplannen.axel_v AS bp WHERE b.geometrie && bp.geometrie AND 
intersects(b.geometrie, bp.geometrie) AND b.bouwvlak_id = 10 AND NOT 
bp.naam = 'Axel';

so I select geometry X using bouwvlak_id=10.

Now I want to use GeometryFromText, but the count I get back is totally 
different (12 versus 2). What am I doing wrong?

SELECT count(*) FROM bestemmingsplannen.bouwvlakken AS b, 
bestemmingsplannen.axel_v AS bp WHERE 
GeometryFromText('MULTIPOLYGON(((51603.74237044 
365820.98748955555,51607.223759734 365821.15731342667,51606.459552328 
365818.18539568223,51603.402722704 365818.8646911667,51603.74237044 
365820.98748955555)))', 28992) && bp.geometrie AND 
intersects(GeometryFromText('MULTIPOLYGON(((51603.74237044 
365820.98748955555,51607.223759734 365821.15731342667,51606.459552328 
365818.18539568223,51603.402722704 365818.8646911667,51603.74237044 
365820.98748955555)))', 28992), bp.geometrie) AND NOT bp.naam = 'Axel';

I verified I am using the right geometry by using the following query:

select AsText(geometrie) from bestemmingsplannen.bouwvlakken b where 
b.bouwvlak_id = 10;

the result is:
astext
"MULTIPOLYGON(((51603.74237044 365820.987489556,51607.223759734 
365821.157313427,51606.459552328 365818.185395682,51603.402722704 
365818.864691167,51603.74237044 365820.987489556)))"

Thanks in advance.

Best regards,
Bart

-- 
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl

_______________________________________________
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