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?
Asked
Active
Viewed 1,013 times
2 Answers
7
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.

Adam Millerchip
- 20,844
- 5
- 51
- 74
2
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!

Pr0methean
- 303
- 4
- 14

Jonas Köritz
- 2,606
- 21
- 33
-
Edited to reflect the fact that it is going to be a C++ SDK as well. Sorry not to clarify earlier. – Mohan May 05 '17 at 21:40