mapbox / mapbox/MapboxGeocoder.swift

Geocoder Options For Allowed Region Does Not Work For Small Areas

Đang mở
#135 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Swift
Star
133
Fork
46
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện tìm kiếm được báo cáo thông qua createOptions(from:) và createBoundingBox(), tập trung vào ForwardGeocodeOptions.allowedRegion và RectangularRegion. So sánh các vùng nhỏ và vùng trên toàn bang bằng các tọa độ được cung cấp, sau đó xác minh rằng geocoder trả về các địa chỉ nằm trong khu vực dự kiến đồng thời loại trừ các địa chỉ khác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
swift
Lĩnh vực
api, mobile-dev
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.