Postgresql 经纬度

增加一列:

add column `location` geometry default 

st_setsrid(st_makepoint((0)::double precision, (0)::double precision), 4326)

使用距离过滤:

1. st_distance( geometry, geometry) 

这个函数有两个坑点, 1,是使用 欧式空间, 2 则返回的单位不是以米或者km

2. st_distance_sphere(geometry, geometry)  

返回的单位是meter

3. st_dwithin(geometry,geometry)

st_dwithin(geography,geography,100米)

坑的是, geography其实是有坐标系的, 同一坐标系才能计算距离

原文地址:https://www.cnblogs.com/lykm02/p/6023707.html