GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Bug: level 1 information not being returned for certain locations  XML
Forum Index -> Administrative Divisions
Author Message
sbeelis



Joined: 14/10/2021 10:06:25
Messages: 1
Offline

I have noticed that the countrySubdivsionJSON call does not behave consistently for different locations. Is this a bug of the API or am I doing something wrong?

I am using the API to retrieve the level 1 administrative name using the following call:

Code:
http://api.geonames.org/countrySubdivisionJSON?lat=<lat>&lng=<long>&username=<user_name>


This works for some places:

Code:
 <a href="http://api.geonames.org/countrySubdivisionJSON?lat=46.451833&lng=7.750217&username=<user_name>" target="_blank" rel="nofollow">http://api.geonames.org/countrySubdivisionJSON?lat=46.451833&lng=7.750217&username=<user_name></a>
 
 {
   "codes": [
     {
       "code": "BE",
       "level":"1",
       "type":"ISO3166-2"
     }
   ],
   "adminCode1":"BE",
   "distance":0,
   "countryCode":"CH",
   "countryName":"Switzerland",
   "adminName1":"Bern"
 }
 


But does not work for others:
Code:
 <a href="http://api.geonames.org/countrySubdivisionJSON?lat=47.667774&lng=-122.401824&username=<user_name>" target="_blank" rel="nofollow">http://api.geonames.org/countrySubdivisionJSON?lat=47.667774&lng=-122.401824&username=<user_name></a>
 
 {
   "distance":0,
   "countryCode":"US",
   "countryName":"United States"
 }
 


Trying to explicitely add the level parameter with the value 1 did not make any difference.

However, when I added the level parameter with the value of 2, suddenly both calls return the level 1 and level 2 information, so obviously the level 1 information exists for both places, but is not returned in the case for Washington State (US) while it is being returned for the canton of Bern in Switzerland.

Code:
 <a href="http://api.geonames.org/countrySubdivisionJSON?lat=47.667774&lng=-122.401824&username=reviewer_scripts&level=2" target="_blank" rel="nofollow">http://api.geonames.org/countrySubdivisionJSON?lat=47.667774&lng=-122.401824&username=reviewer_scripts&level=2</a>
 
 {
   "adminCode2": "033",
   "codes": [
     {
       "code": "WA",
       "level": "1",
       "type": "ISO3166-2"
     }
   ],
   "adminCode1": "WA",
   "adminName2": "King",
   "distance": 0,
   "countryCode": "US",
   "countryName": "United States",
   "adminName1": "Washington"
 }



Digging around a little more, it seems to vary greatly with the region of the world that I am querying:
[list]
[*] Switzerland: works for every location I have tried so far
[*] USA: works in Idaho, does not work in Washington State
[*] Sweden: works in Göteborg (Västra Götaland), does not work in Stockholm (Stockholm)
[*] Australia: does work in Canberra (AUstralian Capital Territory) and Darwin (Northern Territory) but not in Adelaide (South Australia), Hobart (Tasmania) or Melbourne (Victoria)
[/list]

Those not working don't return "adminName1" when queried without the level argument or with level=1 but all of them return adminName1 when queried using level=2.
 
Forum Index -> Administrative Divisions
Go to:   
Powered by JForum 2.1.5 © JForum Team