Class DefaultGeoCoordinateService
java.lang.Object
com.broadleafcommerce.fulfillment.service.geo.DefaultGeoCoordinateService
- All Implemented Interfaces:
GeoCoordinateService
This default implementation is capable of calculating the distance between Addresses that have
their latitude and longitude set. An optional
GeolocationProvider can be provided to
support looking up coordinates for Addresses.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final doubleprotected static final doubleprotected static final doubleprotected static final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddressesHaveCoordinates(com.broadleafcommerce.fulfillment.common.domain.Address... addresses) protected doublecalculateDistance(com.broadleafcommerce.fulfillment.common.domain.Address address1, com.broadleafcommerce.fulfillment.common.domain.Address address2, String radiusUnit) protected doubleconvertKmToMi(Double km) protected doubleconvertMiToKm(Double miles) getDistanceBetweenAddresses(com.broadleafcommerce.fulfillment.common.domain.Address address1, com.broadleafcommerce.fulfillment.common.domain.Address address2, String radiusUnit) Determine the distance between two givenaddresses.protected GeolocationProvidervoidhydrateAddressCoordinates(com.broadleafcommerce.fulfillment.common.domain.Address address) Compute and set thelatitudeandlongitudeof the givenAddresstprotected voidhydrateCoordinatesForAddresses(com.broadleafcommerce.fulfillment.common.domain.Address... addresses) voidsetGeolocationProvider(GeolocationProvider geolocationProvider)
-
Field Details
-
MILES_TO_KM
protected static final double MILES_TO_KM- See Also:
-
KM_TO_MILES
protected static final double KM_TO_MILES- See Also:
-
EARTH_RADIUS
protected static final double EARTH_RADIUS- See Also:
-
ONE_DEGREE
protected static final double ONE_DEGREE- See Also:
-
-
Constructor Details
-
DefaultGeoCoordinateService
public DefaultGeoCoordinateService()
-
-
Method Details
-
hydrateAddressCoordinates
public void hydrateAddressCoordinates(com.broadleafcommerce.fulfillment.common.domain.Address address) Description copied from interface:GeoCoordinateServiceCompute and set thelatitudeandlongitudeof the givenAddresst- Specified by:
hydrateAddressCoordinatesin interfaceGeoCoordinateService- Parameters:
address- TheAddressfor which to determine geographic coordinates.
-
getDistanceBetweenAddresses
@Nullable public Double getDistanceBetweenAddresses(com.broadleafcommerce.fulfillment.common.domain.Address address1, com.broadleafcommerce.fulfillment.common.domain.Address address2, String radiusUnit) Description copied from interface:GeoCoordinateServiceDetermine the distance between two givenaddresses. Returns null if the distance cannot be determined.- Specified by:
getDistanceBetweenAddressesin interfaceGeoCoordinateService- Parameters:
address1- The first location of the measurement.address2- The second location of the measurement.radiusUnit- The unit of measure for the returned value, eitherMILEorKILOMETER.- Returns:
- The distance between the two given Addresses, in the unit specified. Returns null if distance cannot be determined.
-
hydrateCoordinatesForAddresses
protected void hydrateCoordinatesForAddresses(com.broadleafcommerce.fulfillment.common.domain.Address... addresses) -
addressesHaveCoordinates
protected boolean addressesHaveCoordinates(com.broadleafcommerce.fulfillment.common.domain.Address... addresses) -
calculateDistance
protected double calculateDistance(com.broadleafcommerce.fulfillment.common.domain.Address address1, com.broadleafcommerce.fulfillment.common.domain.Address address2, String radiusUnit) -
convertKmToMi
-
convertMiToKm
-
getGeolocationProvider
-
setGeolocationProvider
-