geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.94k stars 517 forks source link

[Pelias] custom address fields #1203

Open mrbig opened 8 months ago

mrbig commented 8 months ago

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.

mrbig commented 8 months ago

@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 commented 8 months ago

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 commented 7 months ago

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