Get list of all important sub-location in a city by city name - rest

I tried to google place API to get a list of all important sub-location within a city but it's not showing the complete list.It gives the result on the basis of some search like restaurant and all.
Is there any API to get a list of all sub-location within the city on the basis of city name?

try something as mentioned below:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=28.7041,77.1025&radius=50000&key=YOUR_API_KEY.
The link of format:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=[LATITUDE AND LONGITUDE OF CITY]&radius=50000[I have specified 50KM which is largest google api allows]&key=YOUR_API_KEY.
Do not specify the type.
radius: you get the approx size of city to restrict the value for radius.

Related

How to find a city(ies) only with partial search?

I am using Nominatim OpenStreetMap API to find city/ cities which matches search phrase.
For example, wind should work like Wind% - not an exact match but it does not work. The second problem is not able to get a city/cities. It returns, administrative, town, county, recreational and etc.
The Nominatim documentation suggests using special words but there is no example.
https://nominatim.openstreetmap.org/?format=json&addressdetails=1&q=winds&format=json&limit=5
The above URL returns 5 places but not a single city. I want to search for cities only. I can use the following which is kind of helpful but it does not search for a partial phrase and returns a result only with exact matcth:
https://nominatim.openstreetmap.org/?format=json&addressdetails=1&city=windsor&format=json&limit=5
If instead of city=windsor I use city=wind it does not return data.
Unfortunately Nominatim doesn't support partial matches. But photon does.

Getting Streets of a specific postcode using Open Street Maps

I want to write a code that has the Countrycode and Postcode as an input and the ouput are the streets that are in the given postcode using some apis that use GSM.
My tactic is as follows:
I need to get the relation Id of the district. For Example 1991416 is the relation id for the third district in Vienna - Austria. It's provided by the nominatim api: http://nominatim.openstreetmap.org/details.php?place_id=158947085
Put the id in this api url: http://polygons.openstreetmap.fr/get_wkt.py?id=1991416&params=0
After downloading the polygon I can put the gathered polygon in this query on the overpass api
(
way
(poly: "polygone data")
["highway"~"^(primary|secondary|tertiary|residential)$"]
["name"];
);
out geom;
And this gives me the streets of the searched district. My two problems with this solution are
1. that it takes quite a time, because asking three different APIs per request isn't that easy on ressources and
2. I don't know how to gather the relation Id from step one automatically. When I enter a Nominatim query like http:// nominatim.openstreetmap.org/search?format=json&country=austria&postalcode=1030 I just get various point in the district, but not the relation id of the searched district in order to get the desired polygone.
So my questions are if someone can tell my how I can get the relation_Id in order to do the mentioned workflow or if there is another, maybe better way to work this issue out.
Thank you for your help!
Best Regards
Daniel
You can simplify your approach quite a bit, down to a single Overpass API call, assuming you define some relevant tags to match the relation in question. In particular, you don't have to resort to using poly at all, i.e. there's no need to convert a relation to a list of lat/lon pairs. Nowadays the concept of an area can be used instead to query for certain objects in a polygon defined by a way or relation. Please check out the documentation for more details on areas.
To get the matching area for relation 1991416, I have used postal_code=1030 and boundary=administrative as filter criteria. Using that area you can then search for ways in this specific polygon:
//uncomment the following line, if you need csv output
//[out:csv(::id, ::type, name)];
//adjust area to your needs, filter critera are the same as for relations
area[postal_code=1030][boundary=administrative]->.a;
// Alternative: {{geocodeArea:name}} -> see
// http://wiki.openstreetmap.org/wiki/Overpass_turbo/Extended_Overpass_Queries
way(area.a)["highway"~"^(primary|secondary|tertiary|residential)$"]["name"];
(._;>;);out meta;
// just for checking if we're looking at the right area
rel(pivot.a);out geom;
Try it on overpass turbo link: http://overpass-turbo.eu/s/6uN
Note: not all ways/relations have a corresponding area, i.e. some area generation rules apply (see wiki page above). For your particular use case you should be ok, however.

An API to get a given city's area size?

I would like to find an API that would return a city's area in square feet, square miles, square meters or any area unit given only the city name.
For example, I query "san francisco" and I get something back like "231.89 sq mi or 600.6 km2".
I need this data for US and Canadian cities for now but it would be nice to have an API that covers any city in the world.
I'd rather avoid scraping wikipedia or any other website and use a proper API if at all possible.
You can use DBpedia to get this information. An example of a SPARQL query to get this information would be:
select ?area where { dbr:San_Francisco dbo:areaTotal ?area }

Associate facebook user check-ins to list of cities based on latitude and longitude

I am studying the development of an application that would show a user which cities in the world their friends have traveled to. To do this, I was thinking of getting a list of check-ins for each of the user's friends and mapping those check-ins to my list of cities based on each check-in latitude and longitude.
This looks like the only way to achieve this since the Facebook graph API doesn't return a city locationId that I could use to map the check-in city to my own city list.
I have absolutely no idea how to perform this mapping from a check-in lat/long to the lat/long I have stored for each city in my city table.
Could anyone point me in the right direction or toward a tutorial explaining how this can be done?
I only have a single pair of lat/long coordinates, so I suppose I would need to define for each city a range of latitudes and longitudes around the city center lat/long that would qualify a check-in for being deemed to take place in any given city, and then do a SQL query against my city table to find which city any given check-in finds itself in?
Or is there another / better way of doing this?
Thanks in advance for any tip and suggestion.
Lothaire
You can use the search API https://developers.facebook.com/docs/reference/api/#searching to search for places around a specific lat/long location.
For example, caffes in San Francisco: https://graph.facebook.com/search?q=coffee&type=place&center=37.76,-122.427&distance=1000
Similarly, you could search for places around your coordinates and look at places type to filter out cities. You would do that by calling https://graph.facebook.com/PLACE_ID and looking at the details. For example, in the search example above, Philz Coffee (first result) - https://graph.facebook.com/151116474914629 - gives you "category": "Local business".
It's not ideal if you're aiming for cities, as check-ins are focused around places people go in the cities (you'd actually have more results of your friends checking into places probably, than them checking in to cities).

Find data near to user location with split data in Xcode

I'm trying to figure out how i can find data (from JSON) near to the users location on iPhone.
My input consists out of 2 parts, so in order to get to the city and address, I have to get an ID from the province where the user is located.
Province (with ID to go to all Json data of the province)
Data
(Every piece of data has a name, city, address, ...)
Is it possible to find the province where the user is located. Then pass its ID to search the list of data for near to the user located events by reversing all the addresses and cities into coordinates,...?
I'm pretty new to location based programming! Any help is appreciated!
Thank you very much!
The first thing you'll want to do is add CoreLocation to your app. This tutorial shows you how to do that. This will give you the latitude and longitude of your current location.
The next thing you'll want to do is reverse geocode your coordinates. One common API for this is the Google Geocoding API. That will give you your province name.