1
使用GIST索引(<->函数)的Postgis 2.0中的最近邻居问题
我正在尝试使用Postgis 2.0新功能<->(几何距离质心),以便为我的表格(cosn1)的每一行计算到同一类最近的多边形的距离。 我正在尝试使用以下代码: WITH index_query AS ( SELECT g1.gid As ref_gid, ST_Distance(g1.the_geom,g2.the_geom) As ENN FROM "cosn1" As g1, "cosn1" As g2 WHERE g1.gid <> g2.gid AND g1.class = g2.class ORDER BY g1.gid, g1.the_geom <-> g2.the_geom) SELECT DISTINCT ON (ref_gid) ref_gid, ENN FROM index_query ORDER BY ref_gid, ENN; 但是后来我意识到了警告: 注意:仅当其中一种几何形状为常数时,索引才会插入(不是在子查询/ cte中)。例如'SRID …