GeocodeQuery WithBounds not strictly used across providers that support it
まだ誰も着手していません。
評価
調査の方向性
まず、Nominatim provider に既存の viewbox と bounded の処理を調べ、次に getGeocodeQueryUrl を通じて Pelias providers を追跡します。GeocodeQuery が getBounds() をどのように公開しているかを、各 provider がサポートする request パラメータと比較します。長方形の範囲をサポートする provider が、provider 固有のデータを重複して要求することなく、一貫して query の範囲を使用すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The WithBounds logic needs to be added to providers, as the method is a base method in the query.
E.g. in Nominatims provider we see:
$viewbox = $query->getData('viewbox');
if (!is_null($viewbox) && is_array($viewbox) && 4 === count($viewbox)) {
$url .= '&'.http_build_query([
'viewbox' => implode(',', $viewbox),
], '', '&', PHP_QUERY_RFC3986);
$bounded = $query->getData('bounded');
if (!is_null($bounded) && true === $bounded) {
$url .= '&'.http_build_query([
'bounded' => 1,
], '', '&', PHP_QUERY_RFC3986);
}
}
The above should instead or in-addition accept $query->getBounds(), because otherwise it forces us to write code like:
// Bounds of EU/UK where our customers are
$euBounds = new Bounds(34.857764, -30.428009, 75.400203, 41.642303);
$geocodeQuery = GeocodeQuery::create($query)
->withBounds($euBounds)
// For Nominatim
->withData('viewbox', $euBounds->toArray());
Pelias Providers and those that extend it don't support it at all -even though Pelias does:
https://github.com/pelias/documentation/blob/master/search.md#search-within-a-rectangular-region
/**
* @param array<string, mixed> $query_data additional query data (API key for instance)
*
* @throws \Geocoder\Exception\Exception
*/
protected function getGeocodeQueryUrl(GeocodeQuery $query, array $query_data = []): string
{
$address = $query->getText();
// This API doesn't handle IPs
if (filter_var($address, FILTER_VALIDATE_IP)) {
throw new UnsupportedOperation(sprintf('The %s provider does not support IP addresses, only street addresses.', $this->getName()));
}
$data = [
'text' => $address,
'size' => $query->getLimit(),
'layers' => null !== $query->getData('layers') ? implode(',', $query->getData('layers')) : null,
'boundary.country' => null !== $query->getData('boundary.country') ? implode(',', $query->getData('boundary.country')) : null,
];
return sprintf('%s/search?%s', $this->root, http_build_query(array_merge($data, $query_data)));
}
- 主要言語
- PHP
- スター
- 4k
- フォーク
- 525
- 平均マージ
- 8分
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
geocoder-php/Geocoder のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
geocoder-php/Geocoder#1272 ·
-
question
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
geocoder-php/Geocoder#1267 · コメント 2 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 38/100
geocoder-php/Geocoder#1244 · コメント 2 件 · リアクション 2 件 ·
-
provider
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
geocoder-php/Geocoder#1243 ·
-
Mapbox Geocoding v6 オープンprovider
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
geocoder-php/Geocoder#1237 · コメント 1 件 · リアクション 1 件 ·
geocoder-php/Geocoder の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getgrav/grav-plugin-api#45 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
RSS-Bridge/rss-bridge#5098 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
phingofficial/phing#2025 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
silverstripe/developer-docs#911 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100