I'm using postGis in a personal project, mainly to determine if a point is inside a Polygon. I realized I was using lat/long instead of long/lat for creating my polygons and using ST_Contains. Thus i used ST_FlipCoordinates
update partnerarea set area = st_flipcoordinates(area)::geometry(Polygon,4326);
But since, I can't manage to have a correct response from ST_Contains.
Here some examples:
. Before flip
SELECT st_AsEWKT(area), ST_Contains(area, ST_GeomFromText('POINT(51.7261050412711 -0.440412894822658)',4326) ) from partnerarea where id=212;
st_asewkt |st_contains
-------------------------------------------------------------------------------------------------------------------------------------------------+-------------
SRID=4326;POLYGON((51.7261050412711 -0.440412894822658,51.7158961385226 0.103410347364843,51.5624858755914 0.320390327833593,51.3090817887527 0.202287300489843,51.257544662456 0.114396675489843,51.2317544106116 -0.264631644822657,51.3176656880587 -0.542036429978907,51.4633463581247 -0.583235160447657,51.6256173634884 -0.555769340135157,51.7261050412711 -0.440412894822658)) | t
After flip :
SELECT st_AsEWKT(area), ST_Contains(area, ST_GeomFromText('POINT(-0.440412894822658 51.7261050412711)',4326) ) from partnerarea where id=212;
st_asewkt |st_contains
-------------------------------------------------------------------------------------------------------------------------------------------------+-------------
SRID=4326;POLYGON((-0.440412894822658 51.7261050412711,0.103410347364843 51.7158961385226,0.320390327833593 51.5624858755914,0.202287300489843 51.3090817887527,0.114396675489843 51.257544662456,-0.264631644822657 51.2317544106116,-0.542036429978907 51.3176656880587,-0.583235160447657 51.4633463581247,-0.555769340135157 51.6256173634884,-0.440412894822658 51.7261050412711)) | f
As you can see, all the coordinates of my polygon have been correctly switched but the call of ST_Contains return false even if I switch the coordinates of the point. Is there something I'm missing here?