查询目标点是否在指定的城市区域内
执行SQL:
select coordinate
from target_coordinate_table tct
where st_within(tct.coordinate, (select polygon from city_polygon_table cpt where id = 1)) = 1;
查询结果:
查询两个目标点的距离
执行SQL
select coordinate, st_distance_sphere(corrdinate, point(106.529617,29.454004)) as distance
from target_coordinate_table;
查询结果:
查询目标点半径范围内的其他点
SELECT *
FROM (
SELECT
coordinate,
st_distance_sphere(coordinate, point(106.529617,29.454004)) as distance
FROM
target_coordinate_table
) AS subquery
WHERE subquery.distance < 20000;