mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
addresses: add postcode in address reference load command
This commit is contained in:
parent
bbb9dc2561
commit
5f8a506c84
@ -51,7 +51,7 @@ class LoadAddressReferenceCommand extends Command
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$addressReferenceArray = static::fetchVendeeBAL();
|
||||
$addressReferenceArray = $this->fetchWFS();
|
||||
$em = $this->entityManager;
|
||||
|
||||
foreach($addressReferenceArray as $a) {
|
||||
@ -78,10 +78,11 @@ class LoadAddressReferenceCommand extends Command
|
||||
* //TODO move this function in App and make the command generic by accepting a fetcher as an argument
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
*/
|
||||
public static function fetchVendeeBAL(): array
|
||||
private function fetchWFS(): array
|
||||
{
|
||||
|
||||
$dataSource = 'Vendée Base d\'adresses locale';
|
||||
$dataSource = 'BAL GeoVendee';
|
||||
$countryCode = 'FR';
|
||||
|
||||
$addressReferenceArray = array();
|
||||
|
||||
@ -92,35 +93,43 @@ class LoadAddressReferenceCommand extends Command
|
||||
|
||||
$jsonContent = json_decode($wfsContent, true);
|
||||
|
||||
dump($jsonContent);
|
||||
|
||||
foreach ($jsonContent['features'] as $key => $value) {
|
||||
dump($key);
|
||||
dump($value);
|
||||
|
||||
$a = new AddressReference();
|
||||
|
||||
$x = $value['geometry']['coordinates'][0];
|
||||
$y = $value['geometry']['coordinates'][1]; //TODO get the coordinates in EPSG:4326
|
||||
$y = $value['geometry']['coordinates'][1];
|
||||
|
||||
$lon = -1.4 + 0.01 * rand(-5, 5);
|
||||
$lat = 46.5 + 0.01 * rand(-5, 5); //TODO temp
|
||||
$lon = -1.4 + 0.01 * rand(-5, 5); //TODO temp: get the coordinates in EPSG:4326
|
||||
$lat = 46.5 + 0.01 * rand(-5, 5); //TODO temp: get the coordinates in EPSG:4326
|
||||
|
||||
$point = Point::fromLonLat($lon, $lat);
|
||||
|
||||
$em = $this->entityManager;
|
||||
|
||||
$country = $em
|
||||
->getRepository('ChillMainBundle:Country')
|
||||
->findOneBy(array('countryCode' => $countryCode));
|
||||
|
||||
$postcode = $em
|
||||
->getRepository('ChillMainBundle:PostalCode')
|
||||
->findOneBy(array('code' => $value['properties']['CODE_POST'], 'country' => $country));
|
||||
|
||||
$a->setRefId($value['properties']['OBJECTID']);
|
||||
$a->setStreet($value['properties']['NOM_AFNOR']);
|
||||
$a->setStreetNumber($value['properties']['NUMERO']);
|
||||
$a->setPoint($point);
|
||||
//$a->setPostcode('1000'); //TODO find postal code from the postal code in $value['properties']['CODE_POST'] //TODO store postcode if not found???
|
||||
$a->setPostcode($postcode);
|
||||
$a->setMunicipalityCode($value['properties']['CODE_INSEE']);
|
||||
$a->setSource($dataSource);
|
||||
|
||||
$addressReferenceArray[] = $a;
|
||||
}
|
||||
|
||||
dump($addressReferenceArray);
|
||||
|
||||
return $addressReferenceArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user