找最近的点:
greatCircleDistance是clickhouse内的函数
clickhouse
select lon,
lat
from
hisdb.t_sea_geo
order by
greatCircleDistance(cast (lon as float),
cast (lat as float ),120,19.5)
limit 1
其他:
说明:
0.03 表示数据库中最小格点数据的分辨率(也就是间隔)
104.03844是传入的参数经度
30.994878是传入的参数纬度
select geocode
from
(
select
geocode,
ABS(lon-cast(104.03844 as Decimal(8, 4))) as lonAbs,
ABS(lat-cast(30.994878 as Decimal(8, 4))) as latAbs
from
public.t_forecast_geo ) t
where
t.lonAbs <= cast(0.03 as Decimal(5, 2))
and
t.latAbs <= cast(0.03 as Decimal(5, 2))
order by
t.lonAbs,
t.latAbs asc
limit 1