nyaruka / phonenumbers

GoLang port of Google's libphonenumber library
MIT License
1.25k stars 148 forks source link

Missing GeoCodes #100

Closed Trial97 closed 3 years ago

Trial97 commented 3 years ago

Hi ,

Thank you for this library. I tried to take the GeoCodes for a number, the java version the number has the GeoCodes is populated but when I try to get it using this library:

    number := "+447825602614"
    num, err := phonenumbers.Parse(number, utils.EmptyString)
    if err != nil {
        return err
    }
    geoCode, err := phonenumbers.GetGeocodingForNumber(num, phonenumbers.GetRegionCodeForNumber(num))
    if err != nil {
        return err
    }

But I do not get any error and yet the geoCode is empty. I hoped that the last update of metadata fixed this but it did not. Am I doing something wrong?

Thanks, Trial97

Trial97 commented 3 years ago

Hi,

I was wondering if you got any solution for us or you might need more time?

Thank you in advance! Trial97

Trial97 commented 3 years ago

Hi,

I investigated this a bit further and compared it to java implementation: It looks like the java library fallbacks to the locale if the region is not found in the hardcoded database: https://github.com/google/libphonenumber/blob/757a1c88aaa4a8aa49a995bb0fe8b14b496ca00c/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java#L93. Do you think this would be a solution for your library as well? If you agree to this approach, I could send you a PR.

Thanks, Trial97