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

[Pelias] custom address fields #1203

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mrbig
Copy link

@mrbig mrbig commented Oct 24, 2023

Pelias is an open source modular geocoder. It support several data sources and tries to find the best match for each query. Unfortunately a lot of this information is hidden in PHP Geocoder. This PR will expose the most important fields through an extended PeliasAddress class.

The solution is similar to the GoogleMaps provider's GoogleAddress, I have also included the with... methods although currently they are not in use.

The change also includes a minor refactor in the provider that leads to better extendability if one would want to override how the results are parsed into addresses.

This is a minor refactor, but can help customization of this provider a lot.
By having a separate method for Address instantiation one might easily override
what fields from Pelias make into the output
This change introduces a new address type for pelias. This exposes the
following properties from the pelias feature:
    - layer
    - confidence
    - source
    - match_type
    - accuracy

These values can be very useful when deciding if the result is accurate enough
or not.
Copy link
Member

@jbelien jbelien left a comment

Choose a reason for hiding this comment

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

Thanks @mrbig !

Could you add documentation for the properties you've added. Are those properties always return by any Pelias instance ?

Please also have a look at the comments made by @norkunas.

Thanks!

… wherever possible

This change does not affect the way this provider behaves, it's only
syntactic sugar.
@mrbig mrbig changed the title Pelias/custom address fields [Pelias] custom address fields Oct 26, 2023
@mrbig
Copy link
Author

mrbig commented Oct 26, 2023

@jbelien I have implemented the changes suggested by @norkunas.

Could you point me to the documentation that I should update? I've included documentation in the code itself, I realize that might not be sufficient.

The fields I have added are always returned to my knowledge. They describe what data source was used, how accurate that data source is considered, could it find the exact location or it did some kind of interpolation.

Our use case:
We are geocoding a large dataset using opensource data. Unfortunately some regions aren't exact in these databases at the moment. So we want to store with the coordinates the accuracy at the time of geocoding, so that after a map update we can go reiterate these addresses and run another geocoding to refine them. But if the result of geocoding change without the accuracy information we even can not decide if the new values are better or worst.

@jbelien
Copy link
Member

jbelien commented Oct 27, 2023

Could you point me to the documentation that I should update? I've included documentation in the code itself, I realize that might not be sufficient.

In src/Provider/Pelias/Model/PeliasAddress.php, could you add the link to the documentation ?

For instance:

/**
 * @link https://github.com/pelias/documentation/blob/master/result_quality.md#confidence Confidence score
 * @var float|null
 */
private ?float $confidence = null;

@mrbig
Copy link
Author

mrbig commented Nov 7, 2023

Hi @jbelien do you need any other change on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants