geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.95k stars 516 forks source link

[Google Maps] do not use duplicate sub locality levels #939

Closed fritzmg closed 5 years ago

fritzmg commented 5 years ago

Fix for #793

If an AdminLevel has the exact same code, name and level, it will lead to an

Administrative level x is defined twice

exception in willdurand\geocoder. This PR filters such AdminLevels. It also works with

$subLocalityLevels = array_filter($subLocalityLevels, function($adminLevel) use ($subLocalityLevels) {
    foreach ($subLocalityLevels as $localityLevel) {
        if ($adminLevel == $localityLevel) {
            return false;
        }
    }
    return true;
});

of course, but I am not sure what the best practise for object comparison is.

jbelien commented 5 years ago

Thanks @fritzmg !

Before reviewing your PR, can you make sure it passes every test ? Thanks.

fritzmg commented 5 years ago

Sure, no problem, I'll check the failling test.

jbelien commented 5 years ago

Sorry, I just had a look at your PR and I can not accept it because it breaks the testReverseWithSubLocalityLevels() test !

Detail: Admin levels should be:

Your PR returns no admin level.

jbelien commented 5 years ago

I submitted a new PR (#943) that should fix issue #793

fritzmg commented 5 years ago

Ah thank you - I unfortunately never got around to look at this.