简体   繁体   中英

Change Location information related with Country to “ISO_3166-2:ES” code

I am using HERE API to search for a request that gives me a Location dta object giving latitude and longitude.

I am receiving Country information in "ISO_3166-1_alpha-3", which is ISO by default. What I need in my code is to distinguiss between latitude and longitude from Balears islands, Canaris Islands or rest of Spain.

The problem that this ISO provocates me is that the country code I receive is 'ESP' and after that, I have to check in code where it comes to get Balears, Canaris or rest.

So, I have checked that "ISO_3166:ES" code would help. Looking for information in developer API guide, I have checked that you can include different params but I haven't see any param in developer API guide to specify this change and I would like to know if any of you know it.

I have search in API guide information about params. I have see a related param called 'CountryCodeType' which gives me the country code according to ISO 3166-1-alpha-3, but this is just what I want to change.

The url I am using is:

String url = https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?
app_id=[API_ID]&
app_code[API_CODE]&
mode=retrieveAreas&
prox=39.56951,2.64745&
language=es 

I expect Country with other format:

 "Location": {
    ....
        "MapView": {
              ....
              "Address": {
                 "Label": "Sant Nicolau, Palma, Islas Baleares, España",
                 "Country": **"ES-IB"**,
                 "State": "Islas Baleares",
                 "County": "Islas Baleares",
                 "City": "Palma",
                 "District": "Sant Nicolau",
                 "PostalCode": "07001",
                 "AdditionalData": [
                   --...
                 ]
             }
       }
}

the output now is:

 "Location": {
    ....
        "MapView": {
              ....
              "Address": {
                 "Label": "Sant Nicolau, Palma, Islas Baleares, España",
                 "Country": "**ESP**",
                 "State": "Islas Baleares",
                 "County": "Islas Baleares",
                 "City": "Palma",
                 "District": "Sant Nicolau",
                 "PostalCode": "07001",
                 "AdditionalData": [
                   --...
                 ]
             }
       }
}```

"ES-IB" is the code for subdivisions, but not country code:

ISO 3166-2:ES is the entry for Spain in ISO 3166-2, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), which defines codes for the names of the principal subdivisions (eg, provinces or states) of all countries coded in ISO 3166-1.

Here API only support 3 letters country code "ESP" (by default) and 2 letters country code "ES" in the country code filed, if you want to retrieve 2 letters, please add "additionaldata=country2" in the request

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM