abstract class AbstractGeometryProvider in Geocoder 8.3
Same name and namespace in other branches
- 8.2 modules/geocoder_geofield/src/Geocoder/Provider/AbstractGeometryProvider.php \Drupal\geocoder_geofield\Geocoder\Provider\AbstractGeometryProvider
Provides an abstract file handler to be used by GeoPHP Wrapper.
Hierarchy
- class \Drupal\geocoder_geofield\Geocoder\Provider\AbstractGeometryProvider implements GeometryProviderInterface
Expanded class hierarchy of AbstractGeometryProvider
File
- modules/
geocoder_geofield/ src/ Geocoder/ Provider/ AbstractGeometryProvider.php, line 12
Namespace
Drupal\geocoder_geofield\Geocoder\ProviderView source
abstract class AbstractGeometryProvider implements GeometryProviderInterface {
/**
* Geophp interface.
*
* @var \Drupal\geofield\GeoPHP\GeoPHPInterface
*/
protected $geophp;
/**
* Geophp Type.
*
* @var string
*/
protected $geophpType = '';
/**
* {@inheritdoc}
*/
public function __construct() {
$this->geophp = \Drupal::service('geofield.geophp');
}
/**
* {@inheritdoc}
*/
public function getName() : string {
return 'geophp_provider';
}
/**
* {@inheritdoc}
*/
public function geocode($filename) : Geometry {
if (file_exists($filename)) {
$geophp_string = file_get_contents($filename);
/* @var \Geometry $geometry */
$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)));
}
/**
* {@inheritdoc}
*/
public function reverse($latitude, $longitude) {
throw new UnsupportedOperation(sprintf('The %s plugin is not able to do reverse geocoding.', $this->geophpType));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractGeometryProvider:: |
protected | property | Geophp interface. | |
AbstractGeometryProvider:: |
protected | property | Geophp Type. | 3 |
AbstractGeometryProvider:: |
public | function |
Geocode a source string. Overrides GeometryProviderInterface:: |
|
AbstractGeometryProvider:: |
public | function |
Returns the Geometry provider's name. Overrides GeometryProviderInterface:: |
3 |
AbstractGeometryProvider:: |
public | function |
Reverse ReverseGeocode. Overrides GeometryProviderInterface:: |
|
AbstractGeometryProvider:: |
public | function |