public function AbstractGeometryProvider::geocode in Geocoder 8.2
Same name and namespace in other branches
- 8.3 modules/geocoder_geofield/src/Geocoder/Provider/AbstractGeometryProvider.php \Drupal\geocoder_geofield\Geocoder\Provider\AbstractGeometryProvider::geocode()
Geocode a source string.
Parameters
string $filename: The file path with data to be geocoded.
Return value
\Geometry The Geometry result.
Throws
\Geocoder\Exception\Exception
Overrides GeometryProviderInterface::geocode
File
- modules/
geocoder_geofield/ src/ Geocoder/ Provider/ AbstractGeometryProvider.php, line 45
Class
- AbstractGeometryProvider
- Provides an abstract file handler to be used by GeoPHP Wrapper.
Namespace
Drupal\geocoder_geofield\Geocoder\ProviderCode
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 NoResult(sprintf('Could not find %s data in file: "%s".', $this->geophpType, basename($filename)));
}