You are here

function location_has_coordinates in Location 5.3

Same name and namespace in other branches
  1. 6.3 location.module \location_has_coordinates()
  2. 7.5 location.module \location_has_coordinates()
  3. 7.3 location.module \location_has_coordinates()
  4. 7.4 location.module \location_has_coordinates()

Check whether a location has coordinates or not.

Parameters

$location The location to check.:

$canonical Is this a location that is fully saved?: If set to TRUE, only the source will be checked.

6 calls to location_has_coordinates()
location_map_link_br_google in supported/location.br.inc
location_map_link_dk_findvej in supported/location.dk.inc
Generate findvej.dk map link.
location_map_link_us_google in supported/location.us.inc
theme_location_de in supported/location.de.inc
_location_expand_location in ./location.module
Process a location element.

... See full list

File

./location.module, line 918
Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…

Code

function location_has_coordinates($location, $canonical = FALSE) {

  // Locations that have been fully saved have an up to date source.
  if ($canonical) {
    return $location['source'] != LOCATION_LATLON_UNDEFINED;
  }

  // Otherwise, we need to do the full checks.
  // If latitude or longitude are empty / missing
  if (empty($location['latitude']) || empty($location['longitude'])) {
    return FALSE;
  }

  // If the latitude or longitude are zeroed (Although it could be a good idea to relax this slightly sometimes)
  if (_location_floats_are_equal($location['latitude'], 0.0) || _location_floats_are_equal($location['longitude'], 0.0)) {
    return FALSE;
  }
  return TRUE;
}