How to get osm_id of the nominatim address component? - openstreetmap

This is the example request to nominatim:
http://nominatim.openstreetmap.org/search?q=milan,%20italy&format=json&addressdetails=1&accept-language=en
This is the address:
"address":{"city":"Milan","county":"Milan","state":"Lombardy","country":"Italy","country_code":"it"}
All of address components have osm_id's and I want to know them, like this:
"address":{"city":["Milan", <milanId>],"county":["Milan", <milanId>],"state":["Lombardy", <lombardyId>],"country":["Italy", <italyId>]}
How can I get them?

Depending on your use-case you can use the is_in query of Overpass API. See the example at overpass turbo for the coordinates of Milan:
[out:json][timeout:25];
is_in(45.4667971,9.1904984);
out;

Related

Node-RED and REST APIs with resource id's

I'm trying to use Node-RED to develop a REST based API. For example, a GET would be:
http://myurl.com/widgets/"widget-id"
where "widget-id" would be 123. I can get this to work using query strings. However, I can't seem to figure out what to put on the http input node to allow a resource id to get passed. Am I missing something obvious? Any ideas on what I need to do?
The other answer is nearly right, it just needs tweaking for Node-RED
If you set the URL in the HTTP Input node to /widget/:id
you can access the widget id in a function node linked to the HTTP Input node as follows:
var id = msg.req.params.id;
if you get all widgets:
router.get('/widgets/', function(data){});
if only one item(for example - 123):
router.get('/widgets/:id(\\d+)', function(data){});
in you're browser or if you using POSTMAN enter http url: http://youredomain.com/widgets/or http://youredomain.com/widgets/123

Why use selectors and not a new URI?

I have a doubt, I have a URI that will bring me all user's account from another rest service. Example:
GET /users/21212/account
Now I have the need to bring 3 kinds of different groups of user's account, something like: "low-account", "medium-account" and "high-account".
But the discussion is, how should I enable this on my endpoint ?
GET /users/21212/accounts/low-account
GET /users/21212/accounts/medium-account
GET /users/21212/accounts/high-account
or
GET /users/21212/accounts/1?selector=low-account
GET /users/21212/accounts/1?selector=medium-account
GET /users/21212/accounts/1?selector=high-account
I'm inclinated to follow the first approach, I think is more intuitive and the manutenability of the code will be easily preserved... What do you think is conceptual right/better and why ?
I would choose the following option:
GET /users/12345/accounts?group=low-account
It will return you all accounts that belong to 'low-account' group for user 12345.
I tend to use query params if they represent something like filtering. Also I would recommend you to take a look at HATEOAS principle. Then you will be more flexible with your URIs.

Nokia MapImage Route REST API max. number of POIs

We are using Route REST API and we experience problem when passing many POIs to HTTP request (parameters "poixN"). Our request has about 1000 POIs and some of them are truncated (hard to count, but definitely not all are shown). Here's an example request (first line is URL, the others are parameters passed with POST):
http://maps.nlp.nokia.com/mia/1.6/route?app_code=<APP_CODE>&app_id=<APP_ID>
h=440
w=1030
poix0=52.2420610745,21.0951604874;FFFFEA00;FFFFEA00;1;.
poix1=52.2420610745,21.0952168365;FFFFEA00;FFFFEA00;1;.
poix2=52.2420610745,21.0951024308;FFFFEA00;FFFFEA00;1;.
poix3=52.2047067699,20.9944339802;FFFFEA00;FFFFEA00;1;.
...
poix940=52.1749134848,20.9056261531;FFEE7AFF;FFEE7AFF;1;.
q=100
Is there a limit for number of POIs? What about other parameters like "r"?
We use enterprise version. Thank you in advance.
Edit
Ok, after some research I know the limit for "poixN" is 99. Any way to increase the limit?
I don't think it is possible to increase the number of POIs available using the Map Image API, but it would be possible to obtain a screenshot of a more complex map using the Enterprise Maps API for JavaScript using the ContextMenu.captureHandler
You can add the captureHandler to a context menu as shown:
var contextMenu = new nokia.maps.map.component.ContextMenu();
contextMenu.addHandler(nokia.maps.map.component.ContextMenu.captureHandler);
map.components.add(contextMenu);
You can then obtain a screenshot with all your POIs, which could then be used for printing for example.The HERE Maps Community on GitHub hosts a working example specifically for printing which uses hi-res tiles from the Map Tile API as well. Note that screen capture only works on the Firefox Browser.
Since you have such a high number of POIs, I would also recommend looking at clustering to avoid overwhelming your users with too much information.

How to get multiple adrresses from GoogleGeocoding API?

I want to retrieve all the address locations (latitude,longitude,format address) for a single 'search address' request (a little vague such as "Tata Consultancy Services") in MapKit.
I searched on the net and came across GoogleMapsAPI WebServices .
http://code.google.com/apis/maps/documentation/geocoding/
But problem with response is that, it returns only a 'single object' in 'results array' response for a address search.
As an example if you search "Tata Consultancy Services" you get only one location whose formatted address is "TCS Rajshree Business Park, Tadiwala Rd, Sangamvadi, Pune, Maharashtra, India".My question is how can i get details of other locations as we all know that this is not the only office of TCS.
I would like to quote two documentation links related to your problem.
http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests
"Generally, only one entry in the "results" array is returned for address lookups, though the geocoder may return several results when address queries are ambiguous".
So you may found one or more result. but as you are requesting it from iPhone and sensor is by default true. you receive nearest matching result for your query.
The solution is "Viewport Biasing".Please find its details at below link under heading name "Viewport Biasing":-
http://code.google.com/apis/maps/documentation/geocoding/#Viewports
Another options you can try on:
try setting sensor as false.
try region biasing as described on the same page cited above.
try some other word like "hotel near placename" and check the
response result

Google MAP Api http Request

I am making an iphone app that enables users to search for a city/town/countries/states by keying in texts in a UISearchbar, I managed to get the reply from google via JSON. It works ok, but I have some unexpected replies for certain places.
When I search for, say, "Vietnam", "China", "Malaysia", "Indonesia" it gives 0 results.
But when I search for, "Singapore", "Cambodia", then, it gives a result fine.
I don't get it, why does some countries aren't available as the search results?
Thanks.
Codes: The http request I sent is something like:
http://maps.google.com/maps/geo?q=%#?output=json
The %# is a searchBar.text formatter.
So if i type Indonesia, basically the request becomes:
http://maps.google.com/maps/geo?q=Indonesia?output=json
Instead of using an undocumented output of maps.google.com, you should try using the Geocoding API:http://code.google.com/apis/maps/documentation/geocoding/#JSON Your query would be something like:
http://maps.googleapis.com/maps/api/geocode/json?address=indonesia&sensor=false