-
Notifications
You must be signed in to change notification settings - Fork 522
[Pelias] custom address fields #1203
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
Open
mrbig
wants to merge
4
commits into
geocoder-php:master
Choose a base branch
from
mrbig:pelias/custom_address_fields
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c815b76
[Pelias] Refactor address instantiation into separate method
mrbig 9c2af7f
[Pelias] return more information from the pelias result set
mrbig 9a19d62
[Pelias] Updated code to use null coalescing operator and typehinting…
mrbig f124341
[Pelias] Fixed phpstan and cs-fixed errors, add documentation to the …
mrbig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Geocoder package. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @license MIT License | ||
*/ | ||
|
||
namespace Geocoder\Provider\Pelias\Model; | ||
|
||
use Geocoder\Model\Address; | ||
|
||
class PeliasAddress extends Address | ||
{ | ||
/** | ||
* The pelias layer returned | ||
* @var string|null | ||
*/ | ||
private $layer; | ||
|
||
/** | ||
* Confidence score from pelias | ||
* @var float|null | ||
*/ | ||
private $confidence; | ||
|
||
/** | ||
* Match type from pelias | ||
* @var string|null | ||
*/ | ||
private $matchType; | ||
|
||
/** | ||
* Data source from pelias | ||
* @var string|null | ||
*/ | ||
private $source; | ||
|
||
/** | ||
* Accuracy from pelias | ||
* @var string|null | ||
*/ | ||
private $accuracy; | ||
|
||
public static function createFromArray(array $data) | ||
{ | ||
$address = parent::createFromArray($data); | ||
$address->layer = $data['layer'] ?? null; | ||
$address->confidence = $data['confidence'] ?? null; | ||
$address->matchType = $data['match_type'] ?? null; | ||
$address->source = $data['source'] ?? null; | ||
$address->accuracy = $data['accuracy'] ?? null; | ||
return $address; | ||
} | ||
|
||
/** | ||
* Get the pelias layer returned | ||
* | ||
* @return string|null | ||
*/ | ||
public function getLayer() | ||
{ | ||
return $this->layer; | ||
} | ||
|
||
/** | ||
* Get confidence score from pelias | ||
* | ||
* @return float|null | ||
*/ | ||
public function getConfidence() | ||
{ | ||
return $this->confidence; | ||
} | ||
|
||
/** | ||
* Get match type from pelias | ||
* | ||
* @return string|null | ||
*/ | ||
public function getMatchType() | ||
{ | ||
return $this->matchType; | ||
} | ||
|
||
/** | ||
* Get data source from pelias | ||
* | ||
* @return string|null | ||
*/ | ||
public function getSource() | ||
{ | ||
return $this->source; | ||
} | ||
|
||
/** | ||
* Get accuracy from pelias | ||
* | ||
* @return string|null | ||
*/ | ||
public function getAccuracy() | ||
{ | ||
return $this->accuracy; | ||
} | ||
|
||
/** | ||
* Set the pelias layer returned | ||
* @param string|null $layer name of the pelias layer | ||
* @return PeliasAddress | ||
*/ | ||
public function withLayer(string $layer = null) | ||
{ | ||
$new = clone $this; | ||
$new->layer = $layer; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Set confidence score from pelias | ||
* @param float|null $confidence confidence level as a float | ||
* @return PeliasAddress | ||
*/ | ||
public function withConfidence(float $confidence = null) | ||
{ | ||
$new = clone $this; | ||
$new->confidence = $confidence; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Set match type from pelias | ||
* @param string|null $matchType precision of the match like "exact" | ||
* @return PeliasAddress | ||
*/ | ||
public function withMatchType(string $matchType = null) | ||
{ | ||
$new = clone $this; | ||
$new->matchType = $matchType; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Set data source from pelias | ||
* @param string|null $source address source from pelias | ||
* @return PeliasAddress | ||
*/ | ||
public function withSource(string $source = null) | ||
{ | ||
$new = clone $this; | ||
$new->source = $source; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Set accuracy from pelias | ||
* @param string|null $accuracy accuracy level from pelias like "point" | ||
* @return PeliasAddress | ||
*/ | ||
public function withAccuracy(string $accuracy = null) | ||
{ | ||
$new = clone $this; | ||
$new->accuracy = $accuracy; | ||
|
||
return $new; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.