情况一:
数据库:只有point类型的location字段
实体类:有经纬度字段(double)、originLoction字段(存放string类型的数据库location字段:POINT(123.462202 41.804471) )
单位:km
查询方圆100千米以内的数据..
SELECT
*,
AsText(location) as originLoction,
(st_distance(location, point(116.397915,39.908946))*111) AS distance
FROM
oc_district
HAVING
distance<100
ORDER BY
distance limit 100;
情况二:
数据库:有经度纬度字段,但是没有point字段
实体类:有经纬度字段(double)、originLoction字段(存放string类型的数据库location字段:POINT(123.462202 41.804471) )
以米m为单位
查询方圆5000m以内的数据
SELECT
*,
(st_distance (point (lng,lat),point (116.3424590000,40.0497810000))*111195/1000 ) as juli
FROM
oc_district
WHERE
juli <=5000
ORDER BY
juli ASC
来源:https://www.cnblogs.com/Soy-technology/p/10981124.html
本文链接:https://my.lmcjl.com/post/1212.html
展开阅读全文
4 评论