postgis查询输入坐标周边n米范围内的记录
2018-11-24 本文已影响0人
铭净止水
8000多记录一二百毫秒就能出结果:
select *,st_distance(ST_GeomFromText('POINT(119.383341323 36.8461558610001)',4326),t.geom,true) closestdistance,st_asgeojson(t.geom) geo from line t where ST_DWithin(ST_GeomFromText('POINT(119.383341323 36.8461558610001)',4326)::geography,t.geom::geography,100)
主要是ST_DWithin快,比创建缓冲区再判断叠加关系快得多