mapbox / mapbox/MapboxGeocoder.swift

focalLocation not returning expected results

オープン
#110 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Swift
スター
133
フォーク
46
PR マージ指標
30日以内にマージされた PR はありません

説明

Using the example code, plus adding a bit to show placemarks returned from ForwardGeocodeOptions, I came up with this testing code:

func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
        geocodingDataTask?.cancel()
         self.outputText.text = ""
// Variables.userLat and Variables.userLng are set through locationManager
        let options = ReverseGeocodeOptions(coordinate: CLLocationCoordinate2D(latitude: Variables.userLat, longitude: Variables.userLng))
        geocodingDataTask = geocoder.geocode(options) { [unowned self] (placemarks, attribution, error) in
            if let error = error {
                NSLog("%@", error)
            } else if let placemarks = placemarks, !placemarks.isEmpty {
                self.resultsLabel.text = placemarks[0].qualifiedName
                let foptions = ForwardGeocodeOptions(query: self.inputText.text!)
                // To refine the search, you can set various properties on the options object.
                foptions.allowedISOCountryCodes = ["US"]
                foptions.focalLocation = CLLocation(latitude: Variables.userLat, longitude: Variables.userLng)
                let neLat = Variables.userLat + 1.0
                let neLng = Variables.userLng + 1.0
                foptions.allowedRegion?.northEast = CLLocationCoordinate2D(latitude: neLat, longitude: neLng)
                let swLat = Variables.userLat - 1.0
                let swLng = Variables.userLng - 1.0
                foptions.allowedRegion?.southWest = CLLocationCoordinate2D(latitude: swLat, longitude: swLng)
                foptions.allowedScopes = [.address, .pointOfInterest]
                let _ = geocoder.geocode(foptions) { (placemarks, attribution, error) in
                    guard let placemark = placemarks?.first else {
                        return
                    }
                    let coordinate = placemark.location.coordinate
                    print("\(coordinate.latitude), \(coordinate.longitude)")
                    self.inputLat.text = coordinate.latitude.description
                    self.inputLng.text = coordinate.longitude.description
                    var string = ""
                    for mark in placemarks! {
                        if string != "" {
                            string += "\n"
                        }
                        string += mark.qualifiedName
                    }
                    self.outputText.text = string
                }

            } else {
                self.resultsLabel.text = "No results"
            }
        }
    }

That gives me a mini-app to test out the data that is returned when I change locations in the Xcode Simulator.
screenshot 2017-07-12 13 54 09

As you can see from this shot, I have centered the map in Jenks, OK (a small town just outside of Tulsa, OK - sort of a 'central US' location.)

When searching for a common place in that area ("Walmart" - which is based in nearby Arkansas, so there are plenty of them around), you can see that only 2 'local' Walmart's come back in the search.

Now, let's move to Bentonville, AR - the home of Walmart......
screenshot 2017-07-12 13 57 55

And, we get two top new results, but the others are the same (and much farther away than Tulsa, OK.....)

We found that if we add the town to the first of the search, the results are much better:
screenshot 2017-07-12 14 00 11
(similar results are true for every search we did - various cities around the US and with other 'common places' like Quiznos (similar results as Walmart when in their home town of Denver, CO...)

As you can see from my code, I tried using the allowedRegion?.northEast and southWest (as I understand it, those should set the search area to about 100 miles around the location, though I'm not sure I set that up right), though no difference was found from this setup (i.e., with/without I get the same results).

The only 'better' results were by putting in the town name along with the 'common' one (though, oddly, different results were returned if the town name was before or after the common one - I didn't check exactly, though I think they are 'best' (i.e., locations are all pretty near) from putting the town name after the common one)

What can I do to get better results without having to tell the user to enter the town name (not a very desirable plan! :)

Thank you in advance for tips - the lookup is a part of my first app (not the test stuff shown in the pictures! ) and one of the key features the users expect is to pull up 'nearby' common places, so it is an important thing for us that this work much more reliably than we are seeing now.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue にある ForwardGeocodeOptions の例から始め、focalLocation と allowedRegion を変更しながら Walmart の検索を再現します。Jenks、Bentonville、および説明されているその他の場所について返される placemark を比較します。完了条件は、観測されたランキングまたは検索領域の動作がバグかどうかを判断し、具体的な変更を特定することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ios, swift
領域
mobile-dev, search
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。