postgis st_contains 好像没有

postgis st_contains not seems

我是 postgis 的新手,我无法弄清楚为什么我在

中尝试的任何值都是 returns false(在 ST_contains 函数中)
select st_astext(geoma),
st_astext(geomb),
st_contains(geoma,geomb)
from (
    select 
    ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[25.64214,-100.27873]],[[25.69505,-100.37006]],[[25.72599,-100.27702]],[[25.680978320466,-100.25384240723]]],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}}') as geomA,
    ST_GeomFromGeoJSON('{"type":"Point","coordinates":[25.683096, -100.311577]}') as geomB
) as p

我在 google 地图上画了点,据说是为了确认我的数据,但是 returns 错误,根据 google 地图应该是正确的

GeoJSON有几个错误,不符合specification,例如:

  1. 您需要将轴顺序翻转为 (X Y) 或 (lng lat)。现在可能不重要,但如果你尝试做任何其他事情,它就会重要。
  2. 多边形的 LinearRing 确实有问题,需要由一个封闭坐标序列组成。
  3. CRS 属性 是为一个几何体提供的,而不是为另一个几何体提供的,这通常会从 PostGIS 引发 "Operation on mixed SRID geometries" 错误。为两个或 none 几何提供 CRS。

试试这个:

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