query for locations with overpass api - openstreetmap

Hi I'm trying to do a query for locations (City, Street, etc.) with suggestions, just like the search boxes at google maps, openstreetmap.org or the search box on the http://overpass-turbo.eu/ site.
Can anyone help me out?
What I did so far, was this query, but I think it's the wrong approach because it's very slow and the results are bad...
[out:json];
node
["name"~"Berlin"]
["place"~"city|village|town"];
out body;

openstreetmap.org and search box at overpass turbo use Nominatim. See the wiki entry http://wiki.openstreetmap.org/wiki/Nominatim
The following is the JS script used by overpass turbo to query Nominatim: https://github.com/tyrasd/overpass-turbo/blob/master/js/nominatim.js

Related

Overpass API - How to get all sustance amenities

I am using the Overpass API in order to fetch all the amenities. All the amenities are listed on the OSM wiki: Amenities.
I cannot seem to get this to work. I first have tried "amenity"="pub;bar;restaurant". But this does not work and I need to type out all the types. I have also tried "amenity"="sustenance" and "amenity"="pub~restaurant~bar". But none of these return any values.
See the OSM Wiki regarding Overpass QL, especially the section about Value matches regular expression. The syntax is a little bit different from the one you tried. Overpass API by Example is also often helpful and has multiple examples for using regular expressions with multiple values.
The correct query would be: highway~"^(pub|bar|restaurant)"

Google nearby search with multiple keywords

Im trying to fetch both restaurants and cafes from googles Places API using the nearby search query.
Excerpt from my query string:
...&radius=2000&keyword=cafe+restaurant&key=myAPIKey
Using the plus '+' seems to bias towards one keyword type and returns a very limited quantity of places (limited versus using i.e. the restaurant and the cafe keywords on separate queries).
I've also tried using single pipe, %20, double pipe to name a few but nothing seems to work.
I've looked at this SO thread, the solution here (its 7 years old now) uses a workaround making two separate calls which I was hoping has now been resolved within the query string?
Is it possible to query nearby search for two keywords i.e. cafe and restaurant using a single query string?
No, it is not possible. You need to make multiple requests to the API for this, one with keyword=cafe or type=cafe, and the other with keyword=restaurant or type=restaurant.
You may also want to file a feature request for this in Google's Issue Tracker.
Hope this helps!

How to get all place name translations in Nominatim?

OpenStreetMap supports different name translations for places. For example "Moscow" in English and "Москва" in Russian for the same node. But there are also French, German, Bahasa translations and so on. Is there a way to get all these translations in a single request? I know I can use "accept_language" property on a "reverse" request, but in will only return a single translation, and I'd like to get all available translations in one request. Fast googling didn't return any results. Thank you.
Use the osm_type and osm_id fields to retrieve the original OSM element.
Example: The Nominatim query for Moscow will return osm_type: relation and osm_id: 2555133 for the first result. Based on this information we can look at the original OSM element or perform an OSM API query for this element. This will include all name:<lang> tags.
Note: Make sure to look both at the Nominatim usage policy and OSM API usage policy before running automated queries!

Points of interest for zip code

I"m looking for way to get list of points of interests like airports, parks, etc. per zip code using Bing maps. Believe me, I search google but it looks like my google is broken since I can't find anything useful. I just need a way to get that info. If there is like a list that would be even better. Any help is appreciated fellows. Is there a simple URL where I can pass in my bing map key, a category and longitude/latitude and get a list of point of interests?
You could use the NAVTEQ point of interest data sources that are in the Bing spatial Data Services here: https://msdn.microsoft.com/en-us/library/hh478189.aspx
You can use the Query API to filter on the PostalCode property: https://msdn.microsoft.com/en-us/library/gg585126.aspx
Here is an example that gets points of interests that are in zip code 98004 and returns the results as XML:
http://spatial.virtualearth.net/REST/v1/data/f22876ec257b474b82fe2ffcb8393150/NavteqNA/NavteqPOIs?&$filter=PostalCode%20eq%20'98004'&$top=250&o=xml&key=YOUR_BING_MAPS_KEY
That said, make sure that your use case does not go against this restriction in the Bing Maps terms of use:
(h)Use Content that consists of points of interest data to generate
sales leads information in the form of ASCII or other text-formatted
lists of category-specific business listings which (i) include
complete mailing address for each business; and (ii) contain a
substantial portion of such listings for a particular country, city,
state or zip code region.

Fetching Zipcodes falling in between the routes Final and End destination using MapQuest API

I need to fetch zipcodes falling all along the route using MapQuest API.Plz suggest i tried to find on mapquest forum as well as on stack .I also did google but can't manage to find appropriate solution.
Ex : Suppose i define a Route from point A to Point B. Now i need to fetch all zipcodes falling in between this route.
You'll want to look at the Corridor Search, which is part of the Search API Web Service. You have two options; you can either pass in the shapePoints that make up the route (corridor) that you want to search along, or you can use the Directions API to calculate a route and then use the sessionId from the Directions API response as input into the Search request.
Here's an example using the Directions API in conjunction with the Search API:
Use the Directions API to calculate a route between two points. In this example, I'm calculating a route between Denver, CO and Aurora, CO:
http://www.mapquestapi.com/directions/v2/route?key=YOUR-APP-KEY-GOES-HERE&from=Denver,CO&to=Aurora,CO
Locate the sessionId parameter in the response.
Use the Search API to perform a corridor search on the uspostalcodes table. I'm also filtering the results from the table to include just the name of the postal code and none of the other info that is available in the table.
http://www.mapquestapi.com/search/v2/corridor?key=YOUR-APP-KEY-GOES-HERE&sessionId=YOUR-SESSION-ID-GOES-HERE&width=1&buffer=0&hostedData=mqap.uspostalcodes|||POSTCODE
You can adjust the width/buffer options as well to refine your search.
Hope this helps!