GeolocationContains.php in Geolocation Field 8.3
File
modules/geolocation_geometry/src/Plugin/views/join/GeolocationContains.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;
class GeolocationContains extends JoinPluginBase implements JoinPluginInterface {
public function buildJoin($select_query, $table, $view_query) {
$geometry_field = $table['alias'] . '.' . $this->field . '_geometry';
$latitude_field = $this->leftTable . '.' . $this->leftField . '_lat';
$longitude_field = $this->leftTable . '.' . $this->leftField . '_lng';
$condition = "ST_Contains(" . $geometry_field . ", ST_PointFromText(CONCAT('POINT(', " . $longitude_field . ", ' ', " . $latitude_field . ", ')'), 4326))";
$select_query
->addJoin($this->type, $this->table, $table['alias'], $condition);
}
}