44323
2023-11-24 ae9bfd2d66f68a553786ac78b12f4390e65e4e09
cloud-server-account/src/main/java/com/dsh/account/util/GDMapGeocodingUtil.java
@@ -189,7 +189,7 @@
     * @param endLonLat   结束经纬度(目标经纬度)
     * @return java.lang.Long 两个定位点之间的距离
     */
    public String getDistanceTOKilometer(String startLonLat, String endLonLat) {
    public double getDistanceTOKilometer(String startLonLat, String endLonLat) {
        try {
            // 返回起始地startAddr与目的地endAddr之间的距离,单位:米
            Long result = new Long(0);
@@ -200,11 +200,12 @@
            String queryResult = getResponse(queryUrl);
            JSONObject job = JSONObject.parseObject(queryResult);
            JSONArray ja = job.getJSONArray("results");
            if (ja.size() == 0){
                return 0.00;
            }
            JSONObject jobO = JSONObject.parseObject(ja.getString(0));
            result = Long.parseLong(jobO.get("distance").toString());
            double kilDis = (double) result / 1000;
            DecimalFormat decimalFormat = new DecimalFormat("#.00");
            return decimalFormat.format(kilDis);
            return (double) result / 1000;
        } catch (Exception e) {
            throw new RuntimeException();
        }