Reputation: 8843
I am implementing an API and C++ SDK that will return two-letter country codes like "US" for a given latitude/longitude. These ISO 3166-1 alpha-2 are well documented, but there is no code for international waters. Is there a convention for what should be returned in this case?
Upvotes: 4
Views: 1403
Reputation: 2644
Your API could return a 404 not found or an empty string for such a location, this way it would be clear that no country code can be retrieved for the given location. There seems to be no real convention for assigning any kind of code to international waters.
In case of a C++ API, consider adding some kind of status to your returned value to indicate if the lookup has been successful.
Error should always be an option in any API design!
Upvotes: 3
Reputation: 23091
The User-assigned code element section of the Wikipedia ISO 3166-1 alpha-2 article could be useful. Specifically:
UN/LOCODE assigns XZ to represent installations in international waters.
It's not part of ISO 3166, but at least there's an example of how another implementation handled it.
Upvotes: 7