postgresql 坐标距离操作

来源:互联网 发布:linux命令行复制文件 编辑:程序博客网 时间:2024/05/20 15:36

查询规定范围内

SELECT    A . ID,    A ."name"FROM    t_base_customer AWHERE    earth_box (        ll_to_earth (36.702286, 119.195057),        300.0    ) @> ll_to_earth (A .latitude, A .longitude);

按距离排序

SELECT    A . ID,    A ."name",    earth_distance (        ll_to_earth (36.702286, 119.195057),        ll_to_earth (A .latitude, A .longitude)    ) AS distanceFROM    t_base_customer AORDER BY    distance ASC;
原创粉丝点击