Class DefaultGeoCoordinateService

java.lang.Object
com.broadleafcommerce.fulfillment.service.geo.DefaultGeoCoordinateService
All Implemented Interfaces:
GeoCoordinateService

public class DefaultGeoCoordinateService extends Object implements 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 Details

  • 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 the latitude and longitude of the given Address t
      Specified by:
      hydrateAddressCoordinates in interface GeoCoordinateService
      Parameters:
      address - The Address 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 given addresses. Returns null if the distance cannot be determined.
      Specified by:
      getDistanceBetweenAddresses in interface GeoCoordinateService
      Parameters:
      address1 - The first location of the measurement.
      address2 - The second location of the measurement.
      radiusUnit - The unit of measure for the returned value, either
              MILE
              
      or
              KILOMETER
              
      .
      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

      protected double convertKmToMi(Double km)
    • convertMiToKm

      protected double convertMiToKm(Double miles)
    • getGeolocationProvider

      @Nullable protected GeolocationProvider getGeolocationProvider()
    • setGeolocationProvider

      @Autowired public void setGeolocationProvider(@Nullable GeolocationProvider geolocationProvider)