Overpass API get nearby building boundaries from a coordinate(lat/lang) - overpass-api

How can i get the building boundaries with single coordinate using overpass API? Right now i have a coordinate(lat/lang) but with this i would like to get the building boundaries for that perticular coordinates.
Even is it possible to get the building boundaries near by my cordinates(lat/lang) ?

One way to achive this is to search buildings within certain radius from your point using around: function.
[out:json][timeout:25];
( // radius, lat, lon
node["building"](around:7.0, 52.2283207, 21.0133141);
way["building"](around:7.0, 52.2283207, 21.0133141);
relation["building"](around:7.0, 52.2283207, 21.0133141);
);
out body;
>;
out skel qt;

Related

Extract building geometry with overpass

I need to extract building geometry by coordinates
I have this, but as I use around it selects the nearest buildings too.
Is there a way to select only one? the building that includes the coordinates
[out:json][timeout:25];
// adjust the search radius (in meters) here
// gather results
(
// query part for: “building=*”
way["building"](around:5,37.780495290046375,-122.47132010628351);
);
// print results
out body;
>;
out skel qt;
I cannot find anything about selecting only one building (or more generally: the best match only) in the Overpass API documentation, although I do surmise it should be possible.
A workaround would be to compare the coordinates of your matches with the desired coordinates, and only retain the match with smallest distance in radial coordinates.

How can I query the feature that's closest to the geocode result in Mapbox?

I'm trying to create a Mapbox map with thousands of points. I want the user to be able to type an address and a div to be filled with information from the closest point to that address. I'm using the mapbox-gl-geocoder control
What would be perfect is if I could use something like:
geocoder.on('result', function(e) {
var features = map.queryRenderedFeatures(e.result.center)
});
But queryRenderedFeatures doesn't accept latlong coordinates, it requires viewport coordinates.
The next thing I tried was
map.on('moveend', function () {
var xwindow = window.innerWidth / 2;
var ywindow = window.innerHeight / 2;
var xywindow = {'x': xwindow, 'y': ywindow};
var features = map.queryRenderedFeatures(xywindow);
});
That gives results that are near the queried address, but not the closest point. For instance if I geocode an address where I know a point exists, this query will return a different point a few streets away.
Is there a way to use queryRenderedFeatures to get a feature on the location that is returned by the geocode control?
But queryRenderedFeatures doesn't accept latlong coordinates, it requires viewport coordinates.
Yes but you can use map.project that Returns a Point representing pixel coordinates, relative to the map's container, that correspond to the specified geographical location.
Once you have all the features you'll need to get the distance to each of them to find the closest. cheap-ruler would be a good choice for that.
An index like geokdbush probably doesn't make sense here as you're only running it once.

Get Node from Coordinates (long, lat) in Open street maps

Using OSRM API, I found the coordinates of the intersections along a route.
I want to know what are the corresponding node IDs.
Is there any API to find the node IDS from the coordinate points?
Is there any API to find the node IDS from the coordinate points?
Yes. You need to pass annotations=nodes as additional query parameter. routes[i].legs[j].annotations.nodes will be an array of OSM IDs that you can use to link the data with OSM.
Linking this to the coordinates in the step is a little bit complicated: You would need to concatenate all RouteStep.geometry and remove the duplicated coordinates (steps[i].geometry[-1] == steps[i+1].geometry[0]).

How to get the coordinates of the polygon area

How to get the coordinates of the polygon area:
http://wikimapia.org/#lang=en&lat=49.964473&lon=36.262436&z=12&m=b&show=/20421408/Chervonozavodsky-district
You need to use the place.Search function of The Wikimapia API and enter the latitude, longitude and the name of the place as parameters.
The API returns a lot of data separated in blocks. The one you are interested in is the geometry.
You can make tests with the Wikimapia API to filter the results to your needs. With the lat lon parameters and the district name you provided I was able to get the area you needed as the first result.
The places[0].polygon is what you need. A JSON array of coordinates.
Here´s the url I used to get the results:
http://api.wikimapia.org/?key=example&function=place.search&q=Chervonozavodsky-district&lat=49.964473&lon=36.262436&format=json&pack=&language=en&data_blocks=geometry%2C&page=1&count=1
Note that in this example i made the request for a JSON result. But you can also ask for a XML if you prefer.
Hope it helps!

MKMapKit true distance between two annotations

I want to make a application that calculates the distance between the user's current location and the nearest something (store, whatnot). Is there any way to obtain the real distance (following public roads ) instead of a direct distance (line from point A to B) ??
Thank you
Use google API to get the route and distance:
http://code.google.com/apis/maps/documentation/directions/
I don't think you can get the route (following roads) from MKMapKit.
The google maps API will return the route (following roads) as a set of latitude and longitude coordinates. It will also return the calculated distance.