情况一:

  数据库:只有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

相关文章:

  • 2021-12-17
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-09-21
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2022-01-25
  • 2021-12-24
  • 2023-03-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案