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
Modifier and TypeFieldDescriptionprotected static final double
protected static final double
protected static final double
protected static final double
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
addressesHaveCoordinates
(com.broadleafcommerce.fulfillment.common.domain.Address... addresses) protected double
calculateDistance
(com.broadleafcommerce.fulfillment.common.domain.Address address1, com.broadleafcommerce.fulfillment.common.domain.Address address2, String radiusUnit) protected double
convertKmToMi
(Double km) protected double
convertMiToKm
(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 GeolocationProvider
void
hydrateAddressCoordinates
(com.broadleafcommerce.fulfillment.common.domain.Address address) Compute and set thelatitude
andlongitude
of the givenAddress
tprotected void
hydrateCoordinatesForAddresses
(com.broadleafcommerce.fulfillment.common.domain.Address... addresses) void
setGeolocationProvider
(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:GeoCoordinateService
Compute and set thelatitude
andlongitude
of the givenAddress
t- Specified by:
hydrateAddressCoordinates
in interfaceGeoCoordinateService
- Parameters:
address
- TheAddress
for 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:GeoCoordinateService
Determine the distance between two givenaddresses
. Returns null if the distance cannot be determined.- Specified by:
getDistanceBetweenAddresses
in 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, eitherMILE
orKILOMETER
.- 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
-