You are here

public function location_handler_field_location_distance::query in Location 7.3

Same name and namespace in other branches
  1. 6.3 handlers/location_handler_field_location_distance.inc \location_handler_field_location_distance::query()
  2. 7.5 handlers/location_handler_field_location_distance.inc \location_handler_field_location_distance::query()
  3. 7.4 handlers/location_handler_field_location_distance.inc \location_handler_field_location_distance::query()

Called to add the field to a query.

Overrides views_handler_field::query

File

handlers/location_handler_field_location_distance.inc, line 197
Coordinates field handler.

Class

location_handler_field_location_distance

Code

public function query() {
  $this
    ->ensure_my_table();
  $coordinates = location_views_proximity_get_reference_location($this->view, $this->options);
  if (!empty($coordinates)) {
    $this->field_alias = $this->query
      ->add_field(NULL, earth_distance_sql($coordinates['longitude'], $coordinates['latitude'], $this->table_alias), $this->table_alias . '_' . $this->field);
  }
  else {
    $this->field_alias = $this->query
      ->add_field(NULL, "'Unknown'", $this->table_alias . '_' . $this->field);
  }
}