并且保留2位小数,而且按距离远近进行排序
public List<HouseGeoDto> getHouseGeoDistance( String currentLongitude, String currentLatitude) {
List<HouseGeoDto> houseGeoList = infoHouseMapper.getHouseGeoList();
if (CollectionUtil.isNotEmpty(houseGeoList)){
for (HouseGeoDto dto : houseGeoList) {
double distance = getDistance(currentLongitude, currentLatitude, dto.getLongitude(), dto.getLatitude());
dto.setGeoDistance(distance);
}
}
//匿名比较器排序
// List<HouseGeoDto> collect = houseGeoList.stream().sorted(Comparator.comparing(HouseGeoDto::getGeoDistance,Comparator.nullsFirst(String::compareTo))).collect(Collectors.toList());
//匿名比较器排序
/* Collections.sort(houseGeoList, new Comparator<HouseGeoDto>() {
@Override
public int compare(HouseGeoDt