You are here

function location_has_coordinates in Location 7.3

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

Check whether a location has coordinates or not.

Parameters

array $location: The location to check.

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

Return value

bool TRUE when location has coordinates.

10 calls to location_has_coordinates()
location_map_link_br_google in supported/location.br.inc
Google link.
location_map_link_dk_findvej in supported/location.dk.inc
Generate findvej.dk map link.
location_map_link_my_google in supported/location.my.inc
Google link.
location_map_link_my_mapquest in supported/location.my.inc
MapQuest link.
location_map_link_pt_google in supported/location.pt.inc
Google link.

... See full list

File

./location.module, line 1377
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;
}