You are here

public function GeolocationGeometryWithin::buildJoin in Geolocation Field 8.3

Builds the SQL for the join this object represents.

When possible, try to use table alias instead of table names.

Parameters

$select_query: An select query object.

$table: The base table to join.

\Drupal\views\Plugin\views\query\QueryPluginBase $view_query: The source views query.

Overrides JoinPluginBase::buildJoin

File

modules/geolocation_geometry/src/Plugin/views/join/GeolocationGeometryWithin.php, line 20

Class

GeolocationGeometryWithin
Geometry joins.

Namespace

Drupal\geolocation_geometry\Plugin\views\join

Code

public function buildJoin($select_query, $table, $view_query) {

  /** @var \Drupal\Core\Database\Query\Select $select_query */
  $geometry_field = ($table['alias'] ?: $this->table) . '.' . $this->field . '_geometry';
  $within_field = $this->leftTable . '.' . $this->leftField . '_geometry';
  $condition = 'ST_Within(' . $within_field . ', ' . $geometry_field . ')';
  $select_query
    ->addJoin($this->type, $this->table, $table['alias'], $condition);
}