Skip to content

Commit

Permalink
Add Addok provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed Feb 15, 2018
1 parent 606f33c commit 203497e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
],
"require": {
"php": "^7.2",
"geo6/geocoder-php-addok-provider": "^1.0",
"geo6/geocoder-php-bpost-provider": "^1.1",
"geo6/geocoder-php-geopunt-provider": "^1.0",
"geo6/geocoder-php-spw-provider": "^1.0",
Expand Down
7 changes: 4 additions & 3 deletions src/Action/GeocodeChooseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$client = new Guzzle6Client();

$geocoder->registerProviders([
new Provider\Addok\Addok($client, 'http://addok.geocode.be/'),
new Provider\UrbIS\UrbIS($client),
new Provider\Geopunt\Geopunt($client),
new Provider\SPW\SPW($client),
Expand All @@ -119,14 +120,14 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele

$addresses = [];
foreach ($providers as $provider) {
$collection = $geocoder->using($provider)->geocodeQuery(GeocodeQuery::create($formatter->format($address, '%S %n, %z %L')));
$collection = $geocoder->using($provider)->geocodeQuery(GeocodeQuery::create($formatter->format($address, '%n %S, %z %L')));
foreach ($collection as $addr) {
$providedBy = $addr->getProvidedBy();
if (!isset($addresses[$providedBy])) {
$addresses[$providedBy] = [];
}
$addresses[$providedBy][] = [
'address' => $formatter->format($addr, '%S %n, %z %L'),
'address' => $formatter->format($addr, '%n %S, %z %L'),
];
}
}
Expand All @@ -137,7 +138,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$data = [
'title' => substr($config['name'], strpos($config['name'], '/') + 1),
'table' => $table,
'address' => $formatter->format($address, '%S %n, %z %L'),
'address' => $formatter->format($address, '%n %S, %z %L'),
'id' => $result->id,
'results' => $addresses,
];
Expand Down
5 changes: 3 additions & 2 deletions src/Action/GeocodeProcessAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$client = new Guzzle6Client();

$chain = new BatchGeocoderProvider([
new Provider\Addok\Addok($client, 'http://addok.geocode.be/'),
new Provider\UrbIS\UrbIS($client),
new Provider\Geopunt\Geopunt($client),
new Provider\SPW\SPW($client),
Expand Down Expand Up @@ -91,7 +92,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$formatter = new StringFormatter();
$validated = false;

$query = GeocodeQuery::create($formatter->format($address, '%S %n, %z %L'));
$query = GeocodeQuery::create($formatter->format($address, '%n %S, %z %L'));
$query = $query->withLocale(Locale::getDefault());
$query = $query->withData('address', $address);
$result = $geocoder->geocodeQuery($query);
Expand All @@ -109,7 +110,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$validator = new AddressValidator($query->getData('address'), $adapter);

if ($validator->isValid($result->first()) === true) {
$updateData['process_address'] = $formatter->format($result->first(), '%S %n, %z %L');
$updateData['process_address'] = $formatter->format($result->first(), '%n %S, %z %L');
/*$processData['coordinates'] = [
$result->first()->getCoordinates()->getLongitude(),
$result->first()->getCoordinates()->getLatitude(),
Expand Down
6 changes: 3 additions & 3 deletions src/Action/ViewAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$formatter = new StringFormatter();

$diff = Text::renderDiff(Text::diff(
$formatter->format($address, '%S %n, %z %L'),
$formatter->format($address, '%n %S, %z %L'),
$r->process_address
));

Expand Down Expand Up @@ -92,7 +92,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
'locality' => $r->locality,
]);

$addressNotGeocoded[] = $formatter->format($address, '%S %n, %z %L');
$addressNotGeocoded[] = $formatter->format($address, '%n %S, %z %L');
}

$select = $sql->select();
Expand All @@ -112,7 +112,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
'locality' => $r->locality,
]);

$addressInvalid[] = $formatter->format($address, '%S %n, %z %L');
$addressInvalid[] = $formatter->format($address, '%n %S, %z %L');
}

$data = [
Expand Down

0 comments on commit 203497e

Please sign in to comment.