-1

当我对一个纬度进行诺基亚反向地理编码调用时,它会返回一个纬度的两个结果(带有地址的位置)。例如。当我使用以下查询 URL 时:

URL url = new URL("http://reverse.geocoder.cit.api.here.com/6.2/reversegeocode.json?prox=-53.31553,-68.64149999999998,1000&gen=1&mode=retrieveAddresses&app_id=oOnEEaBPJEG9JTqwTyjZ&app_code=WV2t5lCfD0NGpQMEjS2VBw");

我得到以下结果:

{
   "Response":{
      "MetaInfo":{
         "Timestamp":"2013-11-15T10:52:24.684+0000"
      },
      "View":[
         {
            "_type":"SearchResultsViewType",
            "ViewId":0,
            "Result":[
               {
                  "Relevance":1.0,
                  "Distance":615.1,
                  "MatchLevel":"street",
                  "MatchQuality":{
                     "Country":1.0,
                     "State":1.0,
                     "County":1.0,
                     "City":1.0,
                     "District":1.0,
                     "Street":[
                        1.0
                     ],
                     "PostalCode":1.0
                  },
                  "Location":{
                     "LocationId":"Link_811555088_R",
                     "LocationType":"point",
                     "DisplayPosition":{
                        "Latitude":-53.3246228,
                        "Longitude":-68.6432568
                     },
                     "MapView":{
                        "TopLeft":{
                           "Latitude":-53.32214,
                           "Longitude":-68.64146
                        },
                        "BottomRight":{
                           "Latitude":-53.32497,
                           "Longitude":-68.65595
                        }
                     },
                     "Address":{
                        "Label":"257-CH, 6300000 Porvenir, Magallanes y La Antártica Chilena, República de Chile",
                        "Country":"CHL",
                        "State":"Magallanes y La Antártica Chilena",
                        "County":"Tierra del Fuego",
                        "City":"Porvenir",
                        "Street":"257-CH",
                        "PostalCode":"6300000",
                        "AdditionalData":[
                           {
                              "value":"República de Chile",
                              "key":"CountryName"
                           },
                           {
                              "value":"Magallanes y La Antártica Chilena",
                              "key":"StateName"
                           }
                        ]
                     },
                     "MapReference":{
                        "ReferenceId":"811555088",
                        "SideOfStreet":"right",
                        "CountryId":"23488354",
                        "StateId":"23488754",
                        "CountyId":"23489032",
                        "CityId":"23488149"
                     }
                  }
               },
               {
                  "Relevance":1.0,
                  "Distance":627.0,
                  "MatchLevel":"street",
                  "MatchQuality":{
                     "Country":1.0,
                     "State":1.0,
                     "County":1.0,
                     "City":1.0,
                     "District":1.0,
                     "Street":[
                        1.0
                     ],
                     "PostalCode":1.0
                  },
                  "Location":{
                     "LocationId":"Link_925101778_L",
                     "LocationType":"point",
                     "DisplayPosition":{
                        "Latitude":-53.32497,
                        "Longitude":-68.64146
                     },
                     "MapView":{
                        "TopLeft":{
                           "Latitude":-53.32145,
                           "Longitude":-68.64146
                        },
                        "BottomRight":{
                           "Latitude":-53.32497,
                           "Longitude":-68.62151
                        }
                     },
                     "Address":{
                        "Label":"Ruta Complementaria I, 9420 Río Grande, Argentina",
                        "Country":"ARG",
                        "State":"Tierra del Fuego",
                        "County":"Río Grande",
                        "City":"Río Grande",
                        "Street":"Ruta Complementaria I",
                        "PostalCode":"9420",
                        "AdditionalData":[
                           {
                              "value":"Argentina",
                              "key":"CountryName"
                           },
                           {
                              "value":"Tierra del Fuego",
                              "key":"StateName"
                           }
                        ]
                     },
                     "MapReference":{
                        "ReferenceId":"925101778",
                        "SideOfStreet":"left",
                        "CountryId":"23294156",
                        "StateId":"23294735",
                        "CountyId":"3458765894026227595",
                        "CityId":"23294619"
                     }
                  }
               }
            ]
         }
      ]
   }
}

获得两个位置。首先将国家命名为智利,然后将国家命名为阿根廷。哪个是正确的结果?

4

1 回答 1

1

As I can see from the api response, the API itself does not know the answer. Look at this block:

"MatchQuality":{
   "Country":1.0
}

The same country match quality in both results. If you look at this address at google maps - you will see that it is very close to the border. Given that borders are not very precise on maps, it's easy to see why it does not know what country it is.

So, you have two options here:

  1. Pick first one.
  2. Decide by distance to nearest object. You have two objects found nearby, and the one with smaller distance is in Chile. So you can pick it then with high chance that it's right.
于 2013-11-15T11:55:37.977 回答