geocoder-php / geocoder-extra

Geocoder extra features.
MIT License
52 stars 13 forks source link

Geocodio Does not always return a street #20

Closed wilwade closed 9 years ago

wilwade commented 9 years ago

Here is an example query:

https://api.geocod.io/v1/geocode?q=386+BRANAM+ROAD+OLD+FORT+TN+37362&api_key=USE_YOUR_KEY

It returns

"formatted_street": "",
"city": "Oldfort",
"state": "TN",
"zip": "37362"

So that means that we throw an error on https://github.com/geocoder-php/geocoder-extra/blob/master/src/Geocoder/Provider/GeocodioProvider.php#L129

$street = $address['street'] ?: null;

if (!empty($address['suffix'])) {
    $address['street'] .= ' ' . $address['suffix'];
}

Looks to me like $street = $address['street'] ?: null; is supposed to be $address['street'] = isset($address['street']) ? $address['street'] : null; but was typed wrong?

There is also a section in the response that parses the input query into a street, perhaps that should be the default instead of null?

toin0u commented 9 years ago

You're right. See http://3v4l.org/O968T and http://3v4l.org/3O4Jp

Do you mind to make a PR ? :)

wilwade commented 9 years ago

Do you want to default to the returned parsed input query for the street if there is no street?

toin0u commented 9 years ago

Yes I think it's a good idea.

wilwade commented 9 years ago

Note I did send that bad address upstream to Geocod.io. It parses fine with a comma after Road, but it is having trouble parsing it with the Road and the Fort. So one of the two new tests will start failing once they fix it upstream.

toin0u commented 9 years ago

@wilwade Isn't it you wrote here https://github.com/geocoder-php/geocoder-extra/blob/1.x/tests/Geocoder/Tests/Provider/GeocodioProviderTest.php#L85 ?

wilwade commented 9 years ago

It is, although I got a confirmation from Geocodio that they have added that specific address to their regression testing for their new address parser they are working on.

toin0u commented 9 years ago

Thank you :) Shouldn't we close this issue and reopen it when Geocodio fixed their address parser ?