function query()
 {
     $this->ensureMyTable();
     $lat_alias = $this->tableAlias . '.' . $this->definition['field_name'] . '_lat';
     $lon_alias = $this->tableAlias . '.' . $this->definition['field_name'] . '_lon';
     $proximityPlugin = geofield_proximity_load_plugin($this->options['source']);
     $options = $proximityPlugin->getSourceValue($this);
     if ($options != FALSE) {
         $haversine_options = array('origin_latitude' => $options['latitude'], 'origin_longitude' => $options['longitude'], 'destination_latitude' => $lat_alias, 'destination_longitude' => $lon_alias, 'earth_radius' => GEOFIELD_KILOMETERS);
         $this->query->add_orderby(NULL, geofield_haversine($haversine_options), $this->options['order'], $this->tableAlias . '_geofield_distance');
     }
 }
 /**
  * {@inheritdoc}.
  */
 public function query()
 {
     $this->ensureMyTable();
     $lat_alias = $this->tableAlias . '.' . $this->definition['field_name'] . '_lat';
     $lon_alias = $this->tableAlias . '.' . $this->definition['field_name'] . '_lon';
     $proximityPlugin = geofield_proximity_load_plugin($this->options['source']);
     $options = $proximityPlugin->getSourceValue($this);
     if ($options != FALSE) {
         $haversine_options = array('origin_latitude' => $options['latitude'], 'origin_longitude' => $options['longitude'], 'destination_latitude' => $lat_alias, 'destination_longitude' => $lon_alias, 'earth_radius' => $this->options['radius_of_earth']);
         $this->field_alias = $this->query->add_field(NULL, geofield_haversine($haversine_options), $this->tableAlias . '_' . $this->field);
     }
 }
 protected function opSimple($options)
 {
     $this->query->add_where_expression($this->options['group'], geofield_haversine($options) . ' ' . $this->operator . ' ' . $this->value['distance']);
 }