function geofield_handler_filter::query in Geofield 7.2
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides views_handler_filter_numeric::query
File
- views/
handlers/ geofield_handler_filter.inc, line 65 - Distance filter implementation.
Class
- geofield_handler_filter
- @file Distance filter implementation.
Code
function query() {
$proximityPlugin = geofield_proximity_load_plugin($this->options['source']);
$options = $proximityPlugin
->getSourceValue($this);
if ($options) {
$lat_alias = $this->definition['field_name'] . '_lat';
$lon_alias = $this->definition['field_name'] . '_lon';
$this
->ensure_my_table();
$info = $this
->operators();
if (!empty($info[$this->operator]['method'])) {
$haversine_options = array(
'origin_latitude' => $options['latitude'],
'origin_longitude' => $options['longitude'],
'destination_latitude' => $this->table_alias . '.' . $lat_alias,
'destination_longitude' => $this->table_alias . '.' . $lon_alias,
'earth_radius' => $this->value['unit'],
);
$this
->{$info[$this->operator]['method']}($haversine_options);
}
}
}