Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The GeoPlugin provider does not support street addresses, only IP addresses" #192

Open
Mitcal opened this issue Nov 29, 2022 · 2 comments

Comments

@Mitcal
Copy link

Mitcal commented Nov 29, 2022

General Information

GeocoderLaravel Version: 4.4
Laravel Version: 8.79
PHP Version: 8.0
Operating System and Version: linux

Issue Description

[describe what is going wrong in plain english]
Some UK postcodes seem to fail geocoding and I receive the above error.

Steps to Replicate

[please provide a list of specific steps that will allow me to replicate this issue]
$geo = app('geocoder')->geocode('SW1 1AA')->get(); // this postcode is fine, but a very specific few are not.

Stack Trace

[2022-11-29 10:13:30] local.ALERT: Provider "{providerName}" could not geocode address: "{address}". {"exception":"[object] (Geocoder\\Exception\\UnsupportedOperation(code: 0): 
The GeoPlugin provider does not support street addresses, only IP addresses. at /var/www/html/vendor/geocoder-php/geo-plugin-provider/GeoPlugin.php:42)
[stacktrace]
#0 /var/www/html/vendor/geocoder-php/chain-provider/Chain.php(71): Geocoder\\Provider\\GeoPlugin\\GeoPlugin->geocodeQuery()
#1 /var/www/html/vendor/willdurand/geocoder/ProviderAggregator.php(67): Geocoder\\Provider\\Chain\\Chain->geocodeQuery()
#2 /var/www/html/vendor/willdurand/geocoder/ProviderAggregator.php(96): Geocoder\\ProviderAggregator->geocodeQuery()
#3 /var/www/html/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(209): Geocoder\\ProviderAggregator->geocode()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(391): Geocoder\\Laravel\\ProviderAndDumperAggregator->Geocoder\\Laravel\\{closure}()
#5 /var/www/html/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(211): Illuminate\\Cache\\Repository->remember()
#6 /var/www/html/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(101): Geocoder\\Laravel\\ProviderAndDumperAggregator->cacheRequest()
#7 /var/www/html/app/Http/Controllers/JobController.php(406): Geocoder\\Laravel\\ProviderAndDumperAggregator->geocode()
@mikebronner
Copy link
Member

@Mitcal thanks for writing in. This seems to indicate that none of the providers are able to resolve certain postal codes. I would recommend clearing your cache and trying again. If it still persists, I would go to the website of each provider you are using and see if they can resolve the problematic postal codes natively. If that still persists, please provide a list of postal codes that do not work, as well as your geocoded config file, so that I can replicate and see if its an issue in code.

@Mitcal
Copy link
Author

Mitcal commented Nov 29, 2022

Hi @mikebronner,

Thanks for your reply. Here is an example of a postcode that for whatever reason Google Maps can't geocode (even though it shows up on their own maps).

https://maps.googleapis.com/maps/api/geocode/json?address=BR3%201SY&key=GOOGLE_API_KEY

I think I'm using most of the defaults in my config file but here it is:

<?php

use Geocoder\Provider\Chain\Chain;
use Geocoder\Provider\GeoPlugin\GeoPlugin;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Http\Client\Curl\Client;

return [
    'cache' => [

        /*
        |-----------------------------------------------------------------------
        | Cache Store
        |-----------------------------------------------------------------------
        |
        | Specify the cache store to use for caching. The value "null" will use
        | the default cache store specified in /config/cache.php file.
        |
        | Default: null
        |
        */

        'store' => 'geocode',

        /*
        |-----------------------------------------------------------------------
        | Cache Duration
        |-----------------------------------------------------------------------
        |
        | Specify the cache duration in seconds. The default approximates a
        | "forever" cache, but there are certain issues with Laravel's forever
        | caching methods that prevent us from using them in this project.
        |
        | Default: 9999999 (integer)
        |
        */

        'duration' => 9999999,
    ],

    /*
    |---------------------------------------------------------------------------
    | Providers
    |---------------------------------------------------------------------------
    |
    | Here you may specify any number of providers that should be used to
    | perform geocaching operations. The `chain` provider is special,
    | in that it can contain multiple providers that will be run in
    | the sequence listed, should the previous provider fail. By
    | default the first provider listed will be used, but you
    | can explicitly call subsequently listed providers by
    | alias: `app('geocoder')->using('google_maps')`.
    |
    | Please consult the official Geocoder documentation for more info.
    | https://github.com/geocoder-php/Geocoder#providers
    |
    */
    'providers' => [
        Chain::class => [
            GoogleMaps::class => [
                env('GOOGLE_MAPS_LOCALE', 'us'),
                env('GOOGLE_MAPS_API_KEY'),
            ],
            GeoPlugin::class  => [],
        ],
    ],

    /*
    |---------------------------------------------------------------------------
    | Adapter
    |---------------------------------------------------------------------------
    |
    | You can specify which PSR-7-compliant HTTP adapter you would like to use.
    | There are multiple options at your disposal: CURL, Guzzle, and others.
    |
    | Please consult the official Geocoder documentation for more info.
    | https://github.com/geocoder-php/Geocoder#usage
    |
    | Default: Client::class (FQCN for CURL adapter)
    |
    */
    'adapter'  => Client::class,

    /*
    |---------------------------------------------------------------------------
    | Reader
    |---------------------------------------------------------------------------
    |
    | You can specify a reader for specific providers, like GeoIp2, which
    | connect to a local file-database. The reader should be set to an
    | instance of the required reader class or an array containing the reader
    | class and arguments.
    |
    | Please consult the official Geocoder documentation for more info.
    | https://github.com/geocoder-php/geoip2-provider
    |
    | Default: null
    |
    | Example:
    |   'reader' => [
    |       WebService::class => [
    |           env('MAXMIND_USER_ID'),
    |           env('MAXMIND_LICENSE_KEY')
    |       ],
    |   ],
    |
    */
    'reader' => null,

];

It seems like what's happening is the lookup fails, so then it retries the lookup thinking I'm giving an IP address?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants