--
You received this message because you are subscribed to the Google Groups "GeoNames" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geonames+unsubscribe@googlegroups.com.
To post to this group, send email to geon...@googlegroups.com.
Visit this group at https://groups.google.com/group/geonames.
For more options, visit https://groups.google.com/d/optout.
"ERROR: canceling statement due to statement timeout"
Any idea what am i doing wrong here? Please let me know, thanks!!
The easiest would probably just add a fixed size. Say +/- 0.5 degrees. (so south is say lat-0.5, north is lat+0.5)... this would give you in effect the 'biggest city within 0.5 degrees'. rather than the just geographically nearest place (which may be tiny!), or even having to decide what types of places you want.The complication is perhaps if you get nothing useful within 0.5 degrees (ie no cities, or just small places) - may have to repeat the call, using a radius of say 1.0 degree to actually get results.
On 11 April 2017 at 03:54, Panacea <panaceade...@gmail.com> wrote:
Hi,I am a new user to Geonames and very impressed by this API. I have a mobile app which gives me the lat/lng for the user, I want to look up the closest large city atleast within US/Canada maybeworld wide. I came across this post geoname post for finding cityand the reply posted suggested I use a bounding box with the API api.geonames.org/citiesJSON? This service returns a list of cities and placenames in the bounding box, ordered by relevancy (capital/population). This is exactly what I want but I dont understand the bounding box parameters? Can someone please tell me how I can calculate these for a given lat/lngto get the closest large city. If for example im in a suburb of Atlanta, norcross with the following coordinatesNorcrosslat: 33.9,lng: -84.2The closest city would be Atlanta, how can I dynamically get the bounding box parameters from a lat/lng? I would really appreciate your help since i couldnt find this infoThanks in AdvanceFarhan
--
You received this message because you are subscribed to the Google Groups "GeoNames" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geonames+u...@googlegroups.com.
Hi Farhan
Before asking GeoNames you must prepare the bounding box.
You are near Atlanta at lat 33.9° and long -84.2°
To consider a bounding box of say 30 km ‘around’ this point, you must add or subtract these 30 km from your position.
One degree of latitude is about 111 km or 60 nautical miles (about… the earth is not a sphere)
Add and subtract to your latitude in degrees 30km / 111km = 0.27°
Northern limit will be 33.9° + 0.27° = 34.17°
And southern limit 33.9° - 0.27° = 33.63°
One degree of longitude is 111km too but only on the equator… and 0km at the poles.
You must multiply the 111km with the cosine of your latitude
111km * Cosine(33.9°) = 111km * 0.83 = 92.1km
Add and subtract to your longitude in degrees 30km / 92.1km= 0.33°
Eastern limit will be -84.2° + 0.33° = -83.87°
And western limit -84.2° - 0.33° = -84.53°
Then you can ask GeoNames >>>
http://api.geonames.org/citiesJSON?north=34.17&south=33.63&east=-83.87&west=-84.53 &username=demo
Indeed, you may transform the kilometers into your preferred miles…