Ensure ISO3166 list is up to date and ordered by country name not code
geodaniel - October 27, 2006 - 14:18
| Project: | location (API, module) |
| Version: | 6.x-3.x-dev |
| Component: | Data update |
| Category: | task |
| Priority: | normal |
| Assigned: | geodaniel |
| Status: | closed |
Description
There are countries in the official ISO3166-1 list that don't show up in the list of countries in the location module (Isle of Man would be one of them). We should make sure this is up to date according to the current version of the standard.

#1
Hmm, whilst doing that, perhaps we should order those countries alphabetically by name instead of by country code. That should make them appear in the right order to users, for whom the current list causes constant confusion. Think, for example, about 'Germany' between Czech Republic and Djibouti (due to its 'de' code) instead of between Georgia and Ghana where it should fit naturally.
#2
#3
I've attached a patch with a new country list based on the data at http://download.geonames.org/export/dump/countryInfo.txt (CC attribution license), sorted by country name.
There are a number of new additions (Guernsey (gg), Isle of Man (im), Jersey (je), Montenegro (me), Serbia (rs)), some codes that differ from the existing setup (Sweden (sw vs. se), United Kingdom (changed to uk)) and some that just seem to be missing .inc files (Lebanon (lb), Niger (ne)). We still need to add .inc files where necessary.
#4
what speaks against committing this?
#5
I'm not completely happy committing this as there is still an outstanding issue with the likes of Sweden. What should we do with data that had already been entered as sw. Should that be changed to se? What if people have written code based on that in their local system?
There were no comments on the original sw vs. se issue I opened a year ago, so perhaps we don't need to worry so much, but I think we should weigh up some options.
#6
I think the appropriate way to deal w/ this would be to have, in the same revision, an extra function in the location.install file that does an 'UPDATE {location} SET country = 'sw' WHERE country = 'se'
As for people possibly having written code dependent on the hard-coding of a country code -- Ideally, I should be making this thing maintain a changelog for that kinda thing, with a drupal set message in the _update() function describing what changed.
Also, another reason the function is a little off is that I explicity decided to go w/ the ICANN domain letters for a country instead of the ISO but never changed the name of the function. I just couldn't imagine have 'gb' in place of 'uk' for the United Kingdom just because I'm used to seeing ".uk" on the end of a UK domain... I know; it sounds silly.
-Ankur
#7
Updated version of the patch attached, with the sw -> sw database update included (update 6). I've also renamed the sw file to se, leaving a comment for now in the old one in case anyone's wondering what happened. In addition, I've created stub files for gg, im, je, me, rs, lb and ne (Geonames doesn't list any administrative regions for any of these at the moment).
If there are no issues that anybody spots, I'll go ahead and commit this.
#8
I've committed the changes to location.inc, location.install and location.sw.inc on HEAD, DRUPAL-4-7, DRUPAL-5.
I've also added the stub location includes to HEAD and DRUPAL-5, and am trying to figure out how to add them to DRUPAL-4-7 too (I think CVS is choking because I messed up the original commit of the files on DRUPAL-4-7 branch).
#9
You may want to add this to the README or somewhere else prominently. The gb code is in very common use, and this can cause a hiccup for integrating other systems that use ISO3166-1 (e.g. the "Accept-Language" HTTP header).
#10
Just noticed that the ordering of the countries in location.inc seems to have reverted to the list sorted by country code instead of country name as of 1.45.2.5... is it intentional, or is it ok if I go in and fix it up again?
#11
geodaniel, your original patch worked great. I'm guessing no one uses the location module, sorting countries by iso code is extremely confusing for ordinary users.
#12
Changing component to Data update.
#13
Daniel,
fixed on HEAD. Soon on Location 3.
regards,
massa
#14
Thanks... great to see you guys putting a breath of life into Location!
#15
Yeah, I'm excited too!
A good week for geospatial in Drupal!
#16
Automatically closed -- issue fixed for two weeks with no activity.