[postgis-users] Different polygon produced from the same points
Tim Poh
tim.poh at gmail.com
Mon Apr 4 03:24:30 PDT 2005
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.
More information about the postgis-users
mailing list