Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Nominatim Provider #806

Merged
merged 9 commits into from Jan 6, 2018
Merged

Improve Nominatim Provider #806

merged 9 commits into from Jan 6, 2018

Conversation

jbelien
Copy link
Member

@jbelien jbelien commented Dec 29, 2017

Add following fields:

  • Attribution
  • Class
  • Display name
  • OSM type
  • OSM Id
  • Type

Close #805

Add following fields:
- Attribution
- Class
- Display name
- OSM type
- OSM Id
- Type
@Nyholm
Copy link
Member

Nyholm commented Dec 29, 2017

Thank you. After a first review I think it looks good.

Could you fix the style errors and add some tests?

@jbelien
Copy link
Member Author

jbelien commented Dec 29, 2017

Could you fix the style errors and add some tests?

Doing it right now :)

@jbelien
Copy link
Member Author

jbelien commented Dec 29, 2017

Style errors are fixed.

I'm quite new with PHPUnit so it might take some time to write the tests ; I'll do my best :)
What kind of tests do you want me to add ?

@Nyholm
Copy link
Member

Nyholm commented Dec 29, 2017

We just need some integration testing. Ie, write a test and verify the result. The HTTP response will be cached, so make sure to commit the cached file.

It is really just copy paste from existing tests.

I want a test that shows the result has a class, display name, attribution etc.

@jbelien
Copy link
Member Author

jbelien commented Dec 29, 2017

Okay, I'll try to figure this out :P

Add testGeocodeWithRealAddress() ;
Check new fields
Forgot to check displayName
@jbelien
Copy link
Member Author

jbelien commented Dec 29, 2017

I think it's done :)
Tell me if I forgot something.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I like this. I just had a few minors

@@ -169,7 +174,23 @@ private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressN
$builder->setBounds($bounds['south'], $bounds['west'], $bounds['north'], $bounds['east']);
}

return $builder->build();
if (false === $reverse) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this separation? It seams like most the lines are the same.
I suggest to remove the $reverse parameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't really like that solution with reverse parameter either but the API answer from geocoding or reverse geocoding is quite different so the extraction of the files is also different :

Geocoding:
$location = $location->withDisplayName($resultNode->getAttribute('display_name'));
Reverse geocoding:
$location = $location->withDisplayName($resultNode->nodeValue);

Any suggestion to improve/simplify that ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.. Lets improve it by only putting the differences in the if-else-statement. It is a private function so we may improve it later if we come up with anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll take care of that today !

@@ -160,6 +164,7 @@ private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressN
$countryCode = strtoupper($countryCode);
}
$builder->setCountryCode($countryCode);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why what this blank line added?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment, seemd to make more sense to create a "block" with country code process ;
But again, really don't mind putting that back as it was :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey. I just saw a weird diff. This is fine

@@ -149,7 +154,6 @@ private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressN
}
}

$builder->setPostalCode($postalCode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this moved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seemed more logical to regroup postal code process ;
But I really don't mind putting it back to line 152 ^_^

@@ -123,7 +127,7 @@ public function reverseQuery(ReverseQuery $query): Collection
*
* @return Location
*/
private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressNode): Location
private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressNode, string $attribution = 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright', bool $reverse): Location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the default value ever have an effect here?

See https://3v4l.org/F1LKl

Let's remove the default value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

/**
* @param null|string $osmId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I'll fix it !

@jbelien
Copy link
Member Author

jbelien commented Jan 3, 2018

Happy new year ! 🎉

@jbelien
Copy link
Member Author

jbelien commented Jan 4, 2018

Done ! :)

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thanks!

@Nyholm Nyholm merged commit 4d9a5f6 into geocoder-php:master Jan 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants