postgresql ST_Intersects用法

发布时间 2023-03-28 17:03:47作者: 且行且思
ST_Intersects(A,B)经过验证发现,该函数所检索出的对象不仅包括A与B相交,而且包含A存在于B中的情况。因此也可以将其结合ST_Buffer()进行缓冲区内对象检测。

先通过ST_Buffer()函数生成缓冲区对象如存储到onegradebuffe字段中,然后再利用ST_Intersects()函数在表中搜索geom字段表示的对象与onegradebuffe字段表示的缓冲区对象相交的多有对象,即是检索出的缓冲区对象,如:

select objectid from poly where ST_Intersects(ST_Transform(geom,3857),ST_Transform((select onegradebuffer from polytest where objectid=20589),3857))=true 



    @Query(value = "SELECT * FROM gct_park AS gb WHERE ST_Intersects(?1,gb.geom) and gb.city_id in (?2) and deleted = 0", nativeQuery = true)
    List<GctPark> getScopeLayerAdmin(String geo,List<String> cityIds);