mapbox / mapbox/MapboxGeocoder.swift
Geocoder Options For Allowed Region Does Not Work For Small Areas
まだ誰も着手していません。
- 主要言語
- Swift
- スター
- 133
- フォーク
- 46
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I tried to implement a search query for when a user types in an address. All of my users are in the same small area, so I created a relatively small bounding area for my search (~20 miles radius). But, for some reason, when I would search my desired address, which I know should be in my small region. It does not return the address when the user searches for it. The only way I could get the address to show up was to increase the allowed region to the entire state. I even checked that the desired location's coordinates were in the small region, and it returned true. Since my app is only supposed to work in this small city, I would like to be able to only allow the user to select addresses that are in the city and nothing else. Here is my code with comments about which region worked and which one did not:
private func createOptions(from address: String) -> ForwardGeocodeOptions {
let options = ForwardGeocodeOptions(query: address)
options.allowedISOCountryCodes = ["US"]
let indianaUniversity = CLLocation(latitude: 39.1745704, longitude: -86.5173232)
options.focalLocation = indianaUniversity
options.allowedScopes = [.address, .pointOfInterest]
options.allowedRegion = createBoundingBox()
return options
}
private func createBoundingBox() -> RectangularRegion {
let pointOfInterest = CLLocationCoordinate2D(latitude: 39.163899999999998, longitude: -86.522330999999994)
//Works:
//This covers the entire state of Indiana
let indianaNortheastCorner = CLLocationCoordinate2D(latitude: 41.722131, longitude: -84.80896)
let indianaSouthwestCorner = CLLocationCoordinate2D(latitude: 37.822802, longitude: -88.027954)
let indianaRegion = RectangularRegion(southWest: indianaSouthwestCorner, northEast: indianaNortheastCorner)
//return true
indianaRegion.containsLocationCoordinate2D(pointOfInterest)
//Does not work:
//This just covers the Bloomington County area.
let southwestCorner = CLLocationCoordinate2D(latitude: 0, longitude: -86.87026977539062)
let northeastCorner = CLLocationCoordinate2D(latitude: 39.25352462727606, longitude: -86.28971099853516)
let smallRegion = RectangularRegion(southWest: southwestCorner, northEast: northeastCorner)
//returns true
smallRegion.containsLocationCoordinate2D(pointOfInterest)
return indianaRegion
}`
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、createOptions(from:) と createBoundingBox() を通じて報告された検索を再現し、ForwardGeocodeOptions.allowedRegion と RectangularRegion に注目します。提供された座標を使って小さい範囲と州全体の範囲を比較し、その後、ジオコーダーが意図したエリア内の住所を返し、それ以外を除外することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- swift
- 領域
- api, mobile-dev
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100