Download & Extend

geocode_google handler seems to leave out Locality data

Project:Geocode
Version:6.x-1.0-alpha2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

I don't know if this problem is unique to my searches, but every search I was doing was leaving city, street, and zip code data out of the results returned. I tracked it back to the parser setting values like
$this->city = $addr->AdministrativeArea->Locality->LocalityName
when it should have been setting
$this->city = $addr->AdministrativeArea->SubAdministrativeArea->Locality->LocalityName

If this is a widespread issue, the attached patch should solve it.

AttachmentSize
geocode_google_locality_fix.patch1.15 KB

Comments

#1

We're definitely not seeing this, but it could be a locality issue. Can you share some representative addresses that might be used to reproduce this?

#2

Here are a few examples where I'm seeing it.

Los Angeles, CA
Albany
34.0522342,-118.2436849

Edit: Oh, when I click on those links now, I just get an empty result. Copy and paste the links to see a full result. Google must check the referer against the API key (which is missing from those links).

#3

I'm having the same issue. It seems that SubAdministrativeArea is sometimes present, sometimes not. I've included an example below.

The patch in the original post would cause issues for those addresses that do not contain the SubAdministrativeArea (which seems the more common scenario). Attached is a patch that should handle both situations.

Example

Address: 1456 Estrella Way, Turlock

stdClass Object
(
    [name] => 1456 Estrella Way, Turlock
    [Status] => stdClass Object
        (
            [code] => 200
            [request] => geocode
        )

    [Placemark] => Array
        (
            [0] => stdClass Object
                (
                    [id] => p1
                    [address] => 1456 Estrella Way, Turlock, CA 95382, USA
                    [AddressDetails] => stdClass Object
                        (
                            [Accuracy] => 8
                            [Country] => stdClass Object
                                (
                                    [AdministrativeArea] => stdClass Object
                                        (
                                            [AdministrativeAreaName] => CA
                                            [SubAdministrativeArea] => stdClass Object
                                                (
                                                    [Locality] => stdClass Object
                                                        (
                                                            [LocalityName] => Turlock
                                                            [PostalCode] => stdClass Object
                                                                (
                                                                    [PostalCodeNumber] => 95382
                                                                )

                                                            [Thoroughfare] => stdClass Object
                                                                (
                                                                    [ThoroughfareName] => 1456 Estrella Way
                                                                )

                                                        )

                                                    [SubAdministrativeAreaName] => Stanislaus
                                                )

                                        )

                                    [CountryName] => USA
                                    [CountryNameCode] => US
                                )

                        )

                    [ExtendedData] => stdClass Object
                        (
                            [LatLonBox] => stdClass Object
                                (
                                    [north] => 37.5375493
                                    [south] => 37.531254
                                    [east] => -120.8627917
                                    [west] => -120.8690869
                                )

                        )

                    [Point] => stdClass Object
                        (
                            [coordinates] => Array
                                (
                                    [0] => -120.865939
                                    [1] => 37.5343939
                                    [2] => 0
                                )

                        )

                )

        )

)
AttachmentSize
730758-geocode-subadmin.patch 1.17 KB

#4

Marked #829786: City is not allways found as duplicate.

#5

I thinks the #737320: Google geocoder v3 should be done first.

EDIT oups sorry I didn't see they have a patch (I come from the duplicate).

#6

They are now a patch for #737320: Google geocoder v3 that should also solve this issue.