Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

GeocodeQuery WithBounds not strictly used across providers that support it

Đang mở
#1,266 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.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu bằng cách kiểm tra cách xử lý viewbox và bounded hiện có của provider Nominatim, sau đó lần theo các provider Pelias thông qua getGeocodeQueryUrl. So sánh cách GeocodeQuery cung cấp getBounds() với các tham số request được từng provider hỗ trợ. Công việc được coi là hoàn tất khi các provider hỗ trợ giới hạn hình chữ nhật sử dụng nhất quán các giới hạn của query mà không yêu cầu dữ liệu dành riêng cho provider bị trùng lặp.

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

Mô tả

The WithBounds logic needs to be added to providers, as the method is a base method in the query.

E.g. in Nominatims provider we see:

        $viewbox = $query->getData('viewbox');
        if (!is_null($viewbox) && is_array($viewbox) && 4 === count($viewbox)) {
            $url .= '&'.http_build_query([
                'viewbox' => implode(',', $viewbox),
            ], '', '&', PHP_QUERY_RFC3986);

            $bounded = $query->getData('bounded');
            if (!is_null($bounded) && true === $bounded) {
                $url .= '&'.http_build_query([
                    'bounded' => 1,
                ], '', '&', PHP_QUERY_RFC3986);
            }
        }

The above should instead or in-addition accept $query->getBounds(), because otherwise it forces us to write code like:


        // Bounds of EU/UK where our customers are
        $euBounds = new Bounds(34.857764, -30.428009, 75.400203, 41.642303);

        $geocodeQuery = GeocodeQuery::create($query)
            ->withBounds($euBounds)
            // For Nominatim
            ->withData('viewbox', $euBounds->toArray());

Pelias Providers and those that extend it don't support it at all -even though Pelias does:
https://github.com/pelias/documentation/blob/master/search.md#search-within-a-rectangular-region

    /**
     * @param array<string, mixed> $query_data additional query data (API key for instance)
     *
     * @throws \Geocoder\Exception\Exception
     */
    protected function getGeocodeQueryUrl(GeocodeQuery $query, array $query_data = []): string
    {
        $address = $query->getText();

        // This API doesn't handle IPs
        if (filter_var($address, FILTER_VALIDATE_IP)) {
            throw new UnsupportedOperation(sprintf('The %s provider does not support IP addresses, only street addresses.', $this->getName()));
        }

        $data = [
            'text' => $address,
            'size' => $query->getLimit(),
            'layers' => null !== $query->getData('layers') ? implode(',', $query->getData('layers')) : null,
            'boundary.country' => null !== $query->getData('boundary.country') ? implode(',', $query->getData('boundary.country')) : null,
        ];

        return sprintf('%s/search?%s', $this->root, http_build_query(array_merge($data, $query_data)));
    }
Ngôn ngữ chính
PHP
Star
4k
Fork
525
Merge trung bình
8 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

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.

Issue khác của geocoder-php/Geocoder

Tất cả issue của geocoder-php/Geocoder

Issue tương tự

Thêm issue về PHP

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.