AbstractGeometryProvider.php in Geocoder 8.3
File
modules/geocoder_geofield/src/Geocoder/Provider/AbstractGeometryProvider.php
View source
<?php
namespace Drupal\geocoder_geofield\Geocoder\Provider;
use Geometry;
use Geocoder\Exception\LogicException;
use Geocoder\Exception\UnsupportedOperation;
abstract class AbstractGeometryProvider implements GeometryProviderInterface {
protected $geophp;
protected $geophpType = '';
public function __construct() {
$this->geophp = \Drupal::service('geofield.geophp');
}
public function getName() : string {
return 'geophp_provider';
}
public function geocode($filename) : Geometry {
if (file_exists($filename)) {
$geophp_string = file_get_contents($filename);
$geometry = $this->geophp
->load($geophp_string, $this->geophpType);
if (!empty($geometry->components) || $geometry instanceof \Geometry) {
return $geometry;
}
}
throw new LogicException(sprintf('Could not find %s data in file: "%s".', $this->geophpType, basename($filename)));
}
public function reverse($latitude, $longitude) {
throw new UnsupportedOperation(sprintf('The %s plugin is not able to do reverse geocoding.', $this->geophpType));
}
}