You are here

function location_load_location in Location 6.3

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

Load a single location by lid.

Parameters

$lid Location ID to load.:

Return value

A location array.

10 calls to location_load_location()
location_cck_field in contrib/location_cck/location_cck.module
Implementation of hook_field().
location_cck_token_values in contrib/location_cck/location_cck.module
Implementation of hook_token_values().
location_cck_widget in contrib/location_cck/location_cck.module
Implementation of hook_widget().
location_context_create_location in plugins/contexts/location.inc
Create a context, either from configuration or an argument on the URL.
location_handler_field_location_address::render in handlers/location_handler_field_location_address.inc

... See full list

File

./location.module, line 956
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_load_location($lid) {
  $location = db_fetch_array(db_query('SELECT * FROM {location} WHERE lid = %d', $lid));

  // @@@ Just thought of this, but I am not certain it is a good idea...
  if (empty($location)) {
    $location = array(
      'lid' => $lid,
    );
  }
  if (isset($location['source']) && $location['source'] == LOCATION_LATLON_USER_SUBMITTED) {

    // Set up location chooser or lat/lon fields from the stored location.
    $location['locpick'] = array(
      'user_latitude' => $location['latitude'],
      'user_longitude' => $location['longitude'],
    );
  }

  // JIT Geocoding
  // Geocodes during load, useful with bulk imports.
  if (isset($location['source']) && $location['source'] == LOCATION_LATLON_JIT_GEOCODING) {
    if (variable_get('location_jit_geocoding', FALSE)) {
      _location_geo_logic($location, array(
        'street' => 1,
      ), array());
      db_query("UPDATE {location} SET latitude = '%f', longitude = '%f', source = %d WHERE lid = %d", $location['latitude'], $location['longitude'], $location['source'], $location['lid']);
    }
  }
  $location['province_name'] = '';
  $location['country_name'] = '';
  if (!empty($location['country'])) {
    $location['country_name'] = location_country_name($location['country']);
    if (!empty($location['province'])) {
      $location['province_name'] = location_province_name($location['country'], $location['province']);
    }
  }
  $location = array_merge($location, location_invoke_locationapi($location, 'load', $lid));
  return $location;
}