根据经纬度sql计算距离

    xiaoxiao2022-07-06  211

     

    <select id="getChargingStationMapList" parameterType="ChargingStation" resultType="ChargingStation">

    SELECT

    <include refid="chargingStationColumns"/>,

    ROUND(

    6378.138 * 2 * ASIN(

    SQRT(

    POW(

    SIN(

    (

    #{latitude} * PI() / 180 - latitude * PI() / 180

    ) / 2

    ),

    2

    ) + COS(40.042307 * PI() / 180) * COS(latitude * PI() / 180) * POW(

    SIN(

    (

    #{longitude} * PI() / 180 - longitude * PI() / 180

    ) / 2

    ),

    2

    )

    )

    ) * 1000

    ) AS distance

    FROM

    charging_station

    <where>

    del_flag = '0'

    and

    is_effect = '0'

    and

    is_verify = '1'

    </where>

    ORDER BY distance asc, average_score desc

    </select>

    最新回复(0)