|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getGeocoderProvider() |
|
|
public function getGeocoderProvider() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$provider = false ; |
|
|
$symfonyClient = new HttplugClient(); |
|
|
$symfonyClient = new HttplugClient(); |
|
|
|
|
|
$configGeocoderProvider = $this->parameterBag->get('geocoder.provider') ; |
|
|
|
|
|
|
|
|
/* API du gouvernement */ |
|
|
/* API du gouvernement */ |
|
|
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($configGeocoderProvider == 'addok') { |
|
|
|
|
|
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ; |
|
|
|
|
|
} |
|
|
/* Google Maps */ |
|
|
/* Google Maps */ |
|
|
//$provider = new GoogleMaps($symfonyClient, null, '') ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif($configGeocoderProvider == 'googlemaps') { |
|
|
|
|
|
$provider = new GoogleMaps($symfonyClient, null, $this->parameterBag->get('geocoder.api_key')) ; |
|
|
|
|
|
} |
|
|
/* Nominatim : OpenStreetMap */ |
|
|
/* Nominatim : OpenStreetMap */ |
|
|
//$provider = Nominatim::withOpenStreetMapServer($symfonyClient, 'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion'); |
|
|
|
|
|
|
|
|
elseif($configGeocoderProvider == 'nominatim') { |
|
|
|
|
|
$provider = Nominatim::withOpenStreetMapServer($symfonyClient, 'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!$provider) { |
|
|
|
|
|
throw new \ErrorException('Aucun provider (geocoding) défini') ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $provider ; |
|
|
return $provider ; |
|
|
} |
|
|
} |