获取点(纬度,经度)和特定区域的交点

Get the intersection of points (lat,long) and a specific area

我最近接触了 PostgresPostgis 但我似乎无法弄清楚什么是正确的语法。

问题: 我需要一个特定区域内点的 ID 列表。 latlonbigint 类型的两列, cluj.the_geompolygon.

link_geometry: link_id | lat |lon

cluj: the_geom

SELECT link_id 
FROM rou_country_20656215.link_geometry r, cluj 
WHERE ST_Intersects(ST_PointFromText((CAST(r.lon AS float)/100000, CAST(r.lat AS float)/100000), 4326), cluj.the_geom)

我收到以下错误消息:

我提到我无权修改表格。

两个 CAST 表达式两边的括号以及它们之间的逗号导致该表达式被解释为一条记录。那需要是一个字符串。假设您的纬度和经度值是文本(隐含在您的代码中),那么这应该会产生您需要的表达式类型:

SELECT link_id 
FROM rou_country_20656215.link_geometry r, cluj 
WHERE 
    ST_Intersects(
        ST_PointFromText(cast(cast(r.lon AS float)/100000 as text) 
            || cast(cast(r.lat AS float)/100000 as text)), 4326)), 
            cluj.the_geom);

最后我是这样解决的,除了记录解释我没有设置 SRID。

SELECT link_id,
FROM rou_country_20656215.rdf_link_geometry r, rou_country_20656215.cluj c
WHERE ST_Intersects(
           ST_SetSRID(
              ST_MakePoint(CAST(r.lon AS float)/10^5, CAST(r.lat AS float)/10^5),4326),c.the_geom)