City : Lincolnshire State : IL Country : United States Zip : 60069 For the above mentioned location, the coordinates that we are getting from the API are [-100.4458825,39.7837304] which seems to be wrong as the correct coordinates are [-89.4337288, 40.0796606]. Because of the wrong coordinates from the API, Illinois is getting mapped in the center instead of towards right. Can someone help me with this? asked 27 May '19, 08:46 Rayana padmini TZorn
showing 5 of 13
show 8 more comments
|
I wonder if the Java library does somehow modify or remove the comma in the request that separates state and country. Maybe you can check in the actual http traffic. If I do the same request not including the comma I also get the USA as the first result. I have no idea why nominatim handles the requests that different but it would be one explanation and a hint for you how to work around the problem. By escaping it somehow. answered 14 Jun '19, 10:20 TZorn |
What API? What call are you making? What are you using it for?
https://nominatim.openstreetmap.org/search?q= the above is the URL we are calling to get the coordinates
What exact call are you making?
hm. Neither of the above coordinates point to Lincolnshire, IL 60069. It's around [-87.9,42.2]. I wonder if you are doing something fundamentally wrong or are using a different coordinate system.
I found the issue as the responses from the web api and html request of same api from java code are totally different but really don't know why. Can some one help me with this.
Please tell us which exact URL you are calling (including all parameters). And please describe "totally different". The result depends on the parameters you are submitting. Some of those parameters are contained in the HTTP request, for example the Accept-Language header. These may vary between browser requests and requests from within your Java application.
https://nominatim.openstreetmap.org/search?q=IL,+United+States&format=json&addressdetails=1 This is the web api being used .
I think the query you posted above only searches for "IL", not for "Lincolnshire, IL" (typo?)
I was checking for coordinates for IL,United States. The coordinates must be "lat":"40.0796606","lon":"-89.4337288". This was getting in the web api. But when I hit through HTTP request from java, I could get some array of values which contain places different from the response of web api.
The response from web api is
The response from http request from java is
Can you explain what problem you are trying to solve?
SomeoneElse +1
Your problem is not so much the coordinates but that you get different locations returned. Your "web api" call returns Illinois while your "http request from java" returns the United States. Each with the proper coordinates I expect.
You still have not told us what exact request you used for the "java code".
The request I was using from java code is
String mapUrl="https://nominatim.openstreetmap.org/search?q=IL,+United+States&format=json&addressdetails=1"; URL url = new URL(mapUrl); HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection();
And I have used the same url as the web api, but ended up with different results.Yes, the response from httprequest returns the USA, so the coordinates were the coordinates of centre of USA. But don't know why the problem is only with the short form IL.