mybatisplus 给个经纬度判断距离别的经纬度多少米

public Map getPharmacyByMe(double longitude, double latitude) {
Map mapTotal = new HashMap<>();
List list = new ArrayList<>();
try {
    String log=""+longitude;
    String lat1=""+latitude;
    String addCity = JingWeiUtil.getAddCity(lat1, log);
    List sList = pharmacyMapper.selectList(new EntityWrapper()(判断逻辑) );
    List> mapList = new ArrayList<>();
    for (Pharmacy sc : sList) {
        Double lat = Double.parseDouble(sc.getLatitude());
        Double lng = Double.parseDouble(sc.getLongitude());
        Double ju = MapUtil.getDistance(lat, lng, latitude, longitude);
        Map map = new HashMap<>();
        map.put("id", sc.getPharmacyId());
        map.put("name", sc.getPharmacyName());
        map.put("address", sc.getAddress());
        map.put("ju", ju);
        map.put("mobile", sc.getPharmacyPhone());
        map.put("dan", "");
        mapList.add(map);
        Callout out = new Callout();
        out.setContent(sc.getPharmacyName());
        Markers ma = new Markers();
        ma.setCallout(out);
        ma.setLatitude(lat);
        ma.setLongitude(lng);
        ma.setTitle(sc.getPharmacyName());
        ma.setId(sc.getPharmacyId());
        list.add(ma);
    }
    Collections.sort(mapList, new Comparator>() {

        public int compare(Map o1, Map o2) {

            int map1value = (int) Double.parseDouble(o1.get("ju").toString()) * 100;
            int map2value = (int) Double.parseDouble(o2.get("ju").toString()) * 100;
            return map1value - map2value;
        }
    });
    List> mapList1 = new ArrayList<>();
    for(Map ma:mapList) {
        double ju=Double.parseDouble(ma.get("ju").toString());
        DecimalFormat df   = new DecimalFormat("######0.00");
        DecimalFormat    df1   = new DecimalFormat("######0");
        String juli="";
        String dan="";
        if(ju>1000) {
            ju=ju/1000;
            juli=df.format(ju);
            dan="km";
        }else {
            juli=df1.format(ju);
            dan="m";
        }
        ma.put("ju", juli);
        ma.put("dan", dan);
        mapList1.add(ma);
    }

    mapTotal.put("mapList", mapList1);
    mapTotal.put("marList", list);

}

你可能感兴趣的:(mybatisplus 给个经纬度判断距离别的经纬度多少米)