@Override
public List<AppStore> getAppStoreList() {
List<AppStore> newAppStoreList = Lists.newArrayList();
double myLongitude = "我的经度";
double myLatitude = "我的维度";
double raidus = "半径距离";
List<AppStore> appStoreLists = tabUserMapper.getAppStoreList();
newAppStoreList = appStoreLists.stream().filter( appStoreList ->{
double distance = ScopeUtils.getNewDistance(myLongitude,myLatitude,Double.valueOf(appStoreList.getLongitude()),Double.valueOf(appStoreList.getLatitude()));
if (raidus >= distance){
return true;
}else{
return false;
}
}).collect(Collectors.toList());
return newAppStoreList;
}
public static double getNewDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
double lat1 = Math.toRadians(latitude1);
double lat2 = Math.toRadians(latitude2);
double lng1 = Math.toRadians(longitude1);
double lng2 = Math.toRadians(longitude2);
double a = lat1 - lat2;
double b = lng1 - lng2;
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * EARTH_RADIUS;
return s * 1000;
}