localeiso-3166

Determining customary distance unit from ISO 3166 country code


ISO 3166 defines country codes such as GB, US, FR or RU.

I would like a reasonably definitive association from these country codes to the customary unit of measure for distances between places in those countries.

Specifically on iOS and OS X, the country code can be retrieved from NSLocale:

[[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];

NSLocale also provides a way to see if a country uses metric or non metric units:

const bool useMetric = [[[NSLocale currentLocale] objectForKey: NSLocaleUsesMetricSystem] boolValue];

However, this is not sufficient. For example, in Great Britain (GB) the metric system is widely used, but distances between places continue to be officially measured in miles rather than kilometres.


Solution

  • I also faced this problem :-)

    Countries which uses Metric system but still use miles :-- 1. GB is only exception which still uses miles instead of metric. Note: Canada also stared using KMs for road transport. Although, Canada still follows miles for train and horse transport

    Countries which do not uses Metric System Liberia, Myanmar and United States of America. Note: Myanmar (Formerly Burma) is planning to move to metric system. Currently, Myanmar uses its own system different from imperial and metric.

    In my app, i check whether country uses imperial or metric.

    if (metric) then assign kms for all countries except britan

    if (imperial) then assign miles for all countries except Burma

    if burma then assign burma unit

    if britan then assign miles