mapbox / mapbox/MapboxGeocoder.swift

Geocoder Options For Allowed Region Does Not Work For Small Areas

Abierto
#135 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Swift
Estrellas
133
Forks
46
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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
    }`

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo la búsqueda reportada mediante createOptions(from:) y createBoundingBox(), centrándote en ForwardGeocodeOptions.allowedRegion y RectangularRegion. Compara las regiones pequeña y estatal usando las coordenadas proporcionadas y, a continuación, verifica que el geocodificador devuelva direcciones dentro del área prevista y excluya las demás.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
swift
Área
api, mobile-dev
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.