| Author |
Message |
![[Post New]](/gforum/templates/default/images/icon_minipost_new.gif) 19/10/2010 01:04:33
|
ptomblin
![[Avatar]](/gforum/images/avatar/fde9264cf376fffe2ee4ddf4a988880d.jpg)
Joined: 16/10/2007 01:30:57
Messages: 18
Offline
|
I put the lat/long for Pelee Island airport into countrySubdivision, and with a radius of 1, it returns Ontario, Canada, but if I put in a radius of 25, it returns Ohio, United States:
Code:
xen1:~> curl 'http://ws.geonames.org/countrySubdivision?lat=41.778338&lng=-82.678&radius=1'
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames>
<countrySubdivision>
<countryCode>CA</countryCode>
<countryName>Canada</countryName>
<adminCode1>08</adminCode1>
<adminName1>Ontario</adminName1>
<code type="FIPS10-4">08</code>
<code type="ISO3166-2">ON</code>
<distance>1.106012443958574</distance>
</countrySubdivision>
</geonames>
xen1:~> curl 'http://ws.geonames.org/countrySubdivision?lat=41.778338&lng=-82.678&radius=25'
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames>
<countrySubdivision>
<countryCode>US</countryCode>
<countryName>United States</countryName>
<adminCode1>OH</adminCode1>
<adminName1>Ohio</adminName1>
<code type="FIPS10-4">39</code>
<code type="ISO3166-2">OH</code>
<distance>10.431761057611073</distance>
</countrySubdivision>
</geonames>
Shouldn't it return the closest one no matter what the radius is?
|
|
|
 |
![[Post New]](/gforum/templates/default/images/icon_minipost_new.gif) 19/10/2010 03:05:40
|
ptomblin
![[Avatar]](/gforum/images/avatar/fde9264cf376fffe2ee4ddf4a988880d.jpg)
Joined: 16/10/2007 01:30:57
Messages: 18
Offline
|
I'm finding similar results in Serbia near the border with Hungary. With a radius of 1, it returns Serbia, and with a radius of 25, it returns Hungary.
Code:
curl 'http://ws.geonames.org/countrySubdivision?lat=46.042722&lng=19.991028&radius=1'
|
|
|
 |
![[Post New]](/gforum/templates/default/images/icon_minipost_new.gif) 19/10/2010 08:41:33
|
marc
Joined: 08/12/2005 07:39:47
Messages: 4501
Offline
|
The service first tries to use polygon data to resolve the subdivision. For Pelee Island there is no polygon data and the service falls back to the toponyms in the database. If you search with small radius the fallback result is returned, with a larger radius the first matching polygon info is returned.
I am thinking about an improvement. One possible improvement could be to check the toponyms always if the polygon result is not within but in some distance and if the toponym search returns a result closer to the one found from the polygon search the toponym answer is returned.
Marc
|
 |
|
|
 |
![[Post New]](/gforum/templates/default/images/icon_minipost_new.gif) 19/10/2010 13:45:39
|
ptomblin
![[Avatar]](/gforum/images/avatar/fde9264cf376fffe2ee4ddf4a988880d.jpg)
Joined: 16/10/2007 01:30:57
Messages: 18
Offline
|
But surely the border between Canada and the US passes through the middle of the lake so that's where the polygon boundary should be? Or are you considering that the off-shore parts of Canada don't belong to any particular province so the polygons follow the shorelines?
And what about what's happening at 46.094050N ,019.747367E? If you look at that location on Google maps, it's definitely in Serbia, and that's what you get if you ask with a radius of 1, but if you ask with a radius of 25, it returns Hungary. Is that because there isn't a subdivision in Serbia?
I've taken to asking with a radius of 1, and only if that doesn't return anything, asking with a radius of 5, then 25 (with 250ms sleeps between to avoid loading your server down). That seems to do the right thing (to the point where I only have to go beyond a radius of 1 about 9 times out of 750). The only small glitches are Race Rocks 48.300000N,123.533333W and Saturna Island 48.783333N,123.050000W which are not coming up with a province.
|
|
|
 |
![[Post New]](/gforum/templates/default/images/icon_minipost_new.gif) 19/10/2010 14:00:56
|
marc
Joined: 08/12/2005 07:39:47
Messages: 4501
Offline
|
The polygons follow the shore line.
Serbia is a rather new country and we haven't found polygon information for the subdivisions.
You can fix the points that do not return any code when you add the admin divisions to the next toponym. I just did it for Race Rocks:
http://www.geonames.org/6295995/race-rocks-automatic-weather-reporting-system.html
The service now returns "British Columbia".
Best
Marc
|
 |
|
|
 |
|
|