[postgis-users] Different polygon produced from the same poi nts

Gasperi Jerome jerome.gasperi at cnes.fr
Mon Apr 4 04:48:53 PDT 2005


Hi,

According to the postgis documentation :

	The "~" operator returns true if A's bounding box completely contains B's bounding box.

The result you get is then coherent since point X is within the bounding box of your 2 diagrams.

For a "true" contains test, you sould use one of these operators :

	contains(geometry, geometry)
	within(geometry, geometry)
	distance(geometry,geometry) equals to zero 

Regards

Jrom




-----Message d'origine-----
De : Tim Poh [mailto:tim.poh at gmail.com] 
Envoyé : lundi 4 avril 2005 12:25
À : postgis-users at postgis.refractions.net
Objet : [postgis-users] Different polygon produced from the same points


Hi,

I'm new to Postgis and are currently evaluating it. When creating a polygon, i've come across a situation where there could be 2 (or more in othe case) different shape of polygons defined by the same set of points. The 2 diagrams below are created with these SQL insert statements,

INSERT INTO gtest (ID, NAME, GEOM) VALUES (5, 'diagram1', GeomFromText('POLYGON((5 4,5 5,4 4,3 5,3 4,4 3,5 4))', -1));

INSERT INTO gtest (ID, NAME, GEOM) VALUES (6, 'diagram2', GeomFromText('POLYGON((5 4,4 4,5 5,3 5,3 4,4 3,5 4))', -1));


Diagram 1
---------

           A @----------@ B
	      /            /
	    /            /
	  /            /
        /            /
    F @        C @  @ <--- Point X
       \            \
         \            \
           \            \
             \            \
          E @----------@ D

Diagram 2
---------

          A @-------       @ B
	     /         |       /|
	   /           |     /  |
	 /             |   /    |
       /               | /      |
    F @         C @      |
       \                        |
         \                      |
           \                    |
             \                  |
          E @--------------@ D

Now, i'm trying to test the Contain function (~) to test if a point X (shown in diagram 1) is within the polygon. Obviously from the diagram above, Point X is within diagram 2 and not diagram 1. However, my query shows that it is within BOTH polygons,

SELECT name from gtest
WHERE PointFromText( 'POINT(4 4.5)', -1 ) && gtest.geom
AND gtest.geom ~ PointFromText('POINT(4 4.5)',-1);

Now, my question is, could anyone explain such behavior stemming from the above query ? Does postgis recognize the above different polygon shapes due the the sequence of LAT/LONG entered as shown in the INSERT statements above ? Thanks. _______________________________________________
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