Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Country code for international waters

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?

like image 756
Mohan Avatar asked Aug 31 '25 16:08

Mohan


2 Answers

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.

like image 187
Adam Millerchip Avatar answered Sep 10 '25 06:09

Adam Millerchip


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!

like image 43
Jonas Köritz Avatar answered Sep 10 '25 05:09

Jonas Köritz