Class GoogleMapTools


  • public class GoogleMapTools
    extends java.lang.Object
    Spring Bean performing the geo-location HTTP requests towards Google Maps Service.
    • Constructor Detail

      • GoogleMapTools

        public GoogleMapTools()
    • Method Detail

      • getGoogleQuery

        public java.lang.String getGoogleQuery​(AddressData addressData)
      • geocodeAddress

        public GPS geocodeAddress​(Location address)
        geo-codes the given location.
        Parameters:
        address - the address to geocode
        Returns:
        the GPS of the given address
        Throws:
        GeoServiceWrapperException
      • getDistanceAndRoute

        public RouteData getDistanceAndRoute​(Location start,
                                             Location destination)
        creates Distance and Route for the given start/destination locations
        Parameters:
        start - the start location
        destination - the destination location
        Returns:
        the calculated RouteData for the given locations
        Throws:
        GeoServiceWrapperException
      • getDistanceAndRoute

        public RouteData getDistanceAndRoute​(GPS start,
                                             GPS destination)
        creates Distance and Route for the given start/destination GPS
        Parameters:
        start - the start GPS
        destination - the destination GPS
        Returns:
        the calculated RouteData for the given GPS'
        Throws:
        GeoServiceWrapperException
      • getRouteData

        protected RouteData getRouteData​(java.lang.String urlAddress)
      • geocodeAddress

        public GPS geocodeAddress​(AddressData addressData)
        geo-codes the given address data
        Parameters:
        addressData - the address to geocode
        Returns:
        the calculated GPS
        Throws:
        GeoServiceWrapperException
      • appendBusinessParams

        protected java.lang.String appendBusinessParams​(java.lang.String urlAddress)
        Appends business user parameters client and signature. Example URL after appending http://maps.googleapis.com/maps/api/geocode/xml ?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA &client=gme-YOUR_CLIENT_ID &signature=YOUR_URL_SIGNATURE
        Parameters:
        urlAddress -
        Returns:
        url with client id and signature
      • singAndEncodeURL

        protected java.net.URI singAndEncodeURL​(java.lang.String urlAddress)
        Encodes URL query, generates signature and appends it to the query. Return URI to avoid second encoding
        Parameters:
        urlAddress -
        Returns:
        URI
      • isBusinessAPI

        protected boolean isBusinessAPI()
      • setAddressLocationParser

        public void setAddressLocationParser​(org.springframework.web.client.ResponseExtractor<MapLocationData> addressLocationParser)
      • getAddressLocationParser

        protected org.springframework.web.client.ResponseExtractor<MapLocationData> getAddressLocationParser()
      • setRouteDataParser

        public void setRouteDataParser​(org.springframework.web.client.ResponseExtractor<RouteData> routeDataParser)
      • getRouteDataParser

        protected org.springframework.web.client.ResponseExtractor<RouteData> getRouteDataParser()
      • setBaseUrl

        public void setBaseUrl​(java.lang.String baseUrl)
      • getBaseUrl

        protected java.lang.String getBaseUrl()
      • setGoogleKey

        public void setGoogleKey​(java.lang.String googleKey)
      • getGoogleKey

        protected java.lang.String getGoogleKey()
      • setCliendId

        public void setCliendId​(java.lang.String cliendId)
      • getCliendId

        protected java.lang.String getCliendId()
      • setCryptoKey

        public void setCryptoKey​(java.lang.String signature)
      • getCryptoKey

        protected java.lang.String getCryptoKey()