1

I'm creating a polygon and then checks whether one of the origin points is contained inside the polygon. To my surprise, I get False (?!) What is wrong here?

SELECT ST_contains(ST_GeomFromText('POINT (34.8039 32.1049)'),bar.hull)
FROM
(
    SELECT 
    ST_ConvexHull(ST_union(foo.open_line)) as hull
    FROM (
        SELECT ST_GeomFromText('LINESTRING(34.8028 32.1067 ,34.8027 32.1065 ,34.8014 32.1081 ,34.8015 32.1102 ,34.8013 32.114 ,34.8017 32.1111 
                    ,34.8 32.1057 ,34.8014 32.1086 ,34.8041 32.1174 ,34.8075 32.1113 ,34.8072 32.1155 ,34.8 32.1055 ,34.807 32.1098 ,34.8016 32.1126 
                    ,34.8039 32.1049 ,34.8043 32.1048 ,34.8045 32.1061 ,34.8041 32.1172 ,34.8015 32.1139 ,34.8074 32.1135 ,34.8076 32.1136 ,34.8063 32.1173 ,34.8063 32.1175 )') 
        As open_line) 
        As foo
        ) as bar
  • Isn't this a "typo" question -- and thus get closed/deleted? The logic being it's not likely to help others in future. I think that's the policy. – Martin F Apr 9 '14 at 3:56
2

You chose the wrong argument order. This is correct the ST_Contains function

ST_contains(bar.hull,ST_GeomFromText('POINT (34.8039 32.1049)'))

  • point(34.8039 32.1049), is still not inside the polygon.. – Rizon Apr 8 '14 at 10:42
  • Sorry. I forgot swap positions. ST_contains(bar.hull, ST_GeomFromText('POINT (34.8039 32.1049)')) – skedge Apr 8 '14 at 10:45
  • yeah, did you manage to run it and get True? – Rizon Apr 8 '14 at 10:52
  • Yes. It is only part of your query, not all. Use your query and replace the function in the first line – skedge Apr 8 '14 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.