You are here

GeolocationGeometryContains.php in Geolocation Field 8.3

File

modules/geolocation_geometry/src/Plugin/views/join/GeolocationGeometryContains.php
View source
<?php

namespace Drupal\geolocation_geometry\Plugin\views\join;

use Drupal\views\Plugin\views\join\JoinPluginBase;
use Drupal\views\Plugin\views\join\JoinPluginInterface;

/**
 * Geometry joins.
 *
 * @ingroup views_join_handlers
 *
 * @ViewsJoin("geolocation_geometry_contains")
 */
class GeolocationGeometryContains extends JoinPluginBase implements JoinPluginInterface {

  /**
   * {@inheritdoc}
   */
  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_Contains(' . $geometry_field . ', ' . $within_field . ')';
    $select_query
      ->addJoin($this->type, $this->table, $table['alias'], $condition);
  }

}

Classes

Namesort descending Description
GeolocationGeometryContains Geometry joins.