You are here

public function GeoBoundaryFilter::query in Geolocation Field 8.3

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 BoundaryFilter::query

File

modules/geolocation_geometry/src/Plugin/views/filter/GeoBoundaryFilter.php, line 23

Class

GeoBoundaryFilter
Filter handler for search keywords.

Namespace

Drupal\geolocation_geometry\Plugin\views\filter

Code

public function query() {
  if (!$this->query instanceof Sql) {
    return;
  }
  if (empty($this->value)) {
    return;
  }

  // Get the field alias.
  $lat_north_east = $this->value['lat_north_east'];
  $lng_north_east = $this->value['lng_north_east'];
  $lat_south_west = $this->value['lat_south_west'];
  $lng_south_west = $this->value['lng_south_west'];
  if (!is_numeric($lat_north_east) || !is_numeric($lng_north_east) || !is_numeric($lat_south_west) || !is_numeric($lng_south_west)) {
    return;
  }
  $placeholder = $this
    ->placeholder() . '_boundary_geojson';
  $this->query
    ->addWhereExpression($this->options['group'], self::getGeometryBoundaryQueryFragment($this
    ->ensureMyTable(), $this->realField, $placeholder), self::getGeometryBoundaryQueryValue($placeholder, $lat_north_east, $lng_north_east, $lat_south_west, $lng_south_west));
}