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

[Google] Administrative level 1 is defined twice #1173

Closed
guitoon opened this issue Feb 13, 2023 · 4 comments · Fixed by #1174
Closed

[Google] Administrative level 1 is defined twice #1173

guitoon opened this issue Feb 13, 2023 · 4 comments · Fixed by #1174

Comments

@guitoon
Copy link

guitoon commented Feb 13, 2023

Hello, this fix remove double administrative area if they are the same. But I found an address on which Google give 2 different level 1 sublocality:

Rue de Pont-A-Migneloux, 6210 Wayaux, Belgique

image

I this case, the geocoder give me the same error Administrative level 1 is defined twice
How can I solve this issue?

@jbelien jbelien added the bug label Feb 13, 2023
@jbelien jbelien changed the title Administrative level 1 is defined twice [Google] Administrative level 1 is defined twice Feb 13, 2023
@jbelien
Copy link
Member

jbelien commented Feb 19, 2023

A PR (#1174) is ready that should solve this issue!

{
   "results" : [
      {
         "address_components" : [
            ...
            {
               "long_name" : "Wayaux",
               "short_name" : "Wayaux",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Les Bons Villers",
               "short_name" : "Les Bons Villers",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },,
            ...
         ],
         "formatted_address" : "Rue de Pont-à-Migneloux, 6210 Les Bons Villers, Belgique",
         ...
      }
   ],
   "status" : "OK"
}

In this case, it will combine the 2 sublocality_level_1 and return Wayaux / Les Bons Villers as SubLocality Level 1 (see tests).

@guitoon
Copy link
Author

guitoon commented Feb 23, 2023

Nice, thank you

@jbelien
Copy link
Member

jbelien commented Apr 14, 2023

@Stalinko
Copy link

Stalinko commented Dec 20, 2023

hey guys
this bug is still hapenning.

Just try to reverse these coordinates:

        $lat = 22.63376;
        $lng = 88.4147;

It will throw Geocoder\Exception\InvalidArgument "Administrative level 3 is defined twice".

Because the address JSON contains:

            {
               "long_name" : "NDDM Ward No - 26",
               "short_name" : "NDDM Ward No - 26",
               "types" : 
               [
                  "administrative_area_level_3",
                  "political"
               ]
            },
            {
               "long_name" : "North 24 Parganas",
               "short_name" : "North 24 Parganas",
               "types" : 
               [
                  "administrative_area_level_3",
                  "political"
               ]
            },

And your fix doesn't help. Because the exception is thrown before withSubLocalityLevels() call.
Any ideas how to fix it?

UPD in my local fork I've just removed this exception: lumiform/geocoder-php-common@2ce26bd

It causes that the duplicate levels are ignored.

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

Successfully merging a pull request may close this issue.

3 participants