return matchingStores;
}
private Double findStoreDistance(Store store, Integer zip) {
ZipCode zipCode = zipCodeService.findZipCodeByZipCode(zip);
if (zipCode == null) {
return null;
}
// A constant used to convert from degrees to radians.
double degreesToRadians = 57.3;
double storeDistance = 3959 * Math.acos((Math.sin(zipCode.getZipLatitude() / degreesToRadians) * Math.sin(store.getLatitude() / degreesToRadians))
+ (Math.cos(zipCode.getZipLatitude() / degreesToRadians) * Math.cos(store.getLatitude() / degreesToRadians) * Math.cos((store.getLongitude() / degreesToRadians) - (zipCode.getZipLongitude() / degreesToRadians))));
return storeDistance;
}