我是postgis的新手,我无法弄清楚为什么这会为我在点中尝试的任何值返回false(在ST_contains函数中)
{{1}}
我在谷歌地图中绘制了点以确认我的数据,但根据谷歌地图它应该是真的它会返回false
答案 0 :(得分:2)
GeoJSON有几个错误,并且不符合specification,例如:
试试这个:
SELECT ST_AsText(geomA),
ST_AsText(geomB),
ST_Contains(geomA, geomB)
FROM (
SELECT
ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[-100.27873,25.64214],[-100.37006,25.69505],[-100.27702,25.72599],[-100.25384240723,25.680978320466],[-100.27873,25.64214]]],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}}') AS geomA,
ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-100.311577,25.683096],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}}') AS geomB
) AS p;
-[ RECORD 1 ]----------------------------------------------------------------------------------------------------------------------------
st_astext | POLYGON((-100.27873 25.64214,-100.37006 25.69505,-100.27702 25.72599,-100.25384240723 25.680978320466,-100.27873 25.64214))
st_astext | POINT(-100.311577 25.683096)
st_contains | t