mapbox / mapbox/MapboxGeocoder.swift

focalLocation not returning expected results

Aperta
#110 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Swift
Stelle
133
Fork
46
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’esempio di ForwardGeocodeOptions nell’issue e riproduci le ricerche di Walmart modificando focalLocation e allowedRegion. Confronta i placemark restituiti per Jenks, Bentonville e le altre località descritte; il lavoro sarebbe completato dopo aver determinato se il comportamento osservato del ranking o dell’area di ricerca è un bug e aver identificato una modifica concreta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
ios, swift
Ambito
mobile-dev, search
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.