You are here

function location_latlon_exact in Location 7.5

Same name and namespace in other branches
  1. 5.3 location.inc \location_latlon_exact()
  2. 5 location.inc \location_latlon_exact()
  3. 6.3 location.inc \location_latlon_exact()
  4. 7.3 location.inc \location_latlon_exact()
  5. 7.4 location.inc \location_latlon_exact()

Currently, this is not a priority until there is an implementable use for exact longitude, latitude coordinates for an location. The idea is that this call will eventually retrieve information through a web-service. Whereas location_latlon_rough() returns an approximate lat/lon pair based strictly on the postal code where this lat/lon pair is pulled from a database table, this function is intended to send the entire location to a web-service and to retrieve exact lat/lon coordinates.

Parameters

$location: An array where -> the key values are 'street', 'additional', 'province', 'country', 'postal_code' -> the values are: 'street' => the string representing the street location (REQUIRED) 'additional' => the string representing the additional street location portion in the location form 'city' => the city name (REQUIRED) 'province' => the province code defined in the country-specific include file 'country' => the lower-case of the two-letter ISO code (REQUIRED) 'postal_code' => the postal-code (REQUIRED)

Return value

NULL if the delegated-to function that does the actual look-up does not exist. If the appropriate function exists, then this function returns an associative array where 'lon' => A floating point number for the longitude coordinate of the parameter location 'lat' => A floating point number for the latitude coordinate of the parameter location

Related topics

2 calls to location_latlon_exact()
location_latlon_rough_default in ./location.inc
Returns a lat/lon pair of the approximate center of the given postal code in the given country This function is a default implementation, in case the country support doesn't implement a proper function for this.
_location_geo_logic in ./location.module
Perform geocoding logic, etc., prior to storing in the database.

File

./location.inc, line 392

Code

function location_latlon_exact($location = array()) {
  $country = $location['country'];
  location_standardize_country_code($country);
  $service = variable_get('location_geocode_' . $country, 'none');
  if (!empty($country) && $service != 'none') {

    // figure out what the exact function should be
    if (strpos($service, '|')) {
      location_load_country($country);

      // The code change below fixes the problem of the country specific
      // function for geocoding not being correctly called (it removes any
      // text from the pipe (|) onwards)
      $exact_latlon_function = 'location_geocode_' . $country . '_' . substr($service, 0, strpos($service, '|'));
    }
    else {
      location_load_geocoder($service);
      $exact_latlon_function = $service . '_geocode_location';
    }
    if (function_exists($exact_latlon_function)) {
      return $exact_latlon_function($location);
    }
    else {
      return NULL;
    }
  }
  return NULL;
}