maxmind / GeoIP2-perl

Perl API for MaxMind's GeoIP2 web services and databases
https://metacpan.org/release/GeoIP2/
Other
18 stars 11 forks source link

Scotland country and its code #62

Closed KES777 closed 6 years ago

KES777 commented 6 years ago

It is not clean from the doc how next method:

$country_rec->iso_code() This returns the two-character ISO 3166-1 (http://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country.

will deal with Scotland country https://en.wikipedia.org/wiki/ISO_3166-2:GB#Countries_and_province

Is it possible to get three letter country? or its code?

It also worth to show in synopsis or examples the result of expression:

my $country_rec = $insights->country();  # XXXX
print $country_rec->name(), "\n";             # XXXXX
$country_rec->iso_code();                       # UA
oschwald commented 6 years ago

The iso_code method on a country object returns an ISO 3166-1 country code. As such, it will return GB for an IP in Scotland. As you note, Scotland is considered an ISO 3166-2 subdivision and will be the first subdivision of the list returned by ->subdivisions.

Three letter country codes are not provided.

KES777 commented 6 years ago

I check subdivisions and I am ambiguous:

$subdivision_rec->iso_code() This returns a string up to three characters long contain the subdivision portion of the ISO 3166-2 code

But you say:

Three letter country codes are not provided.

oschwald commented 6 years ago

I was referring to ISO 3166-1 countries, which Scotland is not. It is an ISO 3166-2 subdivision. The subdivision codes vary in length between countries.