How do I get the boundingBox for the MapQuest API? - mapquest

The traffic incidents needs the boundingBox param (https://developer.mapquest.com/documentation/traffic-api/incidents/get/) and it docs use a location that is geocoded, I would assume to get the boundingBox info but the geocodding api doesn't return anything for it (https://developer.mapquest.com/documentation/geocoding-api/address/get/). How can I get and/or calculate the bounding box? It seems to be related to the lat/lang but it's not obvious.

A default bounding box can be built around a geocode result by adding/subtracting generous values around the returned lat/lng. But usually the bounding box is a result of a user looking at a map and grabbing the bounds of that map.

Related

How to compute bounding boxes of specific roads from Overpass api

I have a high volume dataset with keys like this:
lat:6.897585,
long:52.785805,
speed:12,
bearing:144
Basically it is a dataset of records of various trips on cars. The data was stored every few seconds during each trip. The main goal of this project is to be able to visualize only u-turns (turn arounds) on a map. But for now, I am trying to at least show the data on specifc roads. For that, I am using Overpass API
With the help of Overpass Turbo, I can get a dataset with all the roads I need.
However, in the dataset, the road's geometry is represented with LineString type.
My question is, How can I get a bounding box(es) of the roads from Overpass API, so later on, I can display events that happened only on the given roads? Or maybe you have a better solution on how to achieve this?
A bounding box wouldn't be very helpful here, as using it to filter your points would show everything that falls within the box (which could include other nearby roads)
It sounds like getting a buffer around a linestring might get you closer, but could still include points that are within the buffer but not on the road you are inspecting.
The smarter way to do this would be to assign each event to a road segment using some logic based on their attributes/properties, so you don't have to depend on a spatial filter.

How do you get the corners of the screen as geographical coordinates for Google Maps using Flutter [duplicate]

I'm trying to find out what is the bounding box of the visible part of google map in flutter's google maps plugin.
Is it possible to get it?
If not is it possible to calculate the bounding box based on zoom level and latitude, longitude of the map center?
That would be GoogleMapController.getVisibleRegion()
Be careful, GoogleMapController.getVisibleRegion() returns a LatLngBounds (a rectangle) and if your map has a tilt then it should not be a rectangle but a trapezoid!
The issue is in the plugin implementation where the returned result is computed only from latLngBounds field whereas it should be computed from farLeft, farRight, nearLeft, nearRight fields.
Reference: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/VisibleRegion
So GoogleMapController.getVisibleRegion() is not accurate and can't be used if there's a tilt.
For reference, an issue has been created: https://github.com/flutter/flutter/issues/74888

Get buildings polygons points from mapbox with fetch API only

I try to get the buildings geometry coordinates polygons from features, but i cant seem to find a way for this to work without the javascript method queryRenderedFeatures or SourceFeatures.
This question Getting building information from mapbox api uses the javascript method, but i want something to work with a link, that i can fetch a json from.
I have managed to come close with something like this:
https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/27.598505,47.162098.json?radius=30&layers=road,poi_label,building,geometry&access_token=ACCESS_TOKEN_HERE.
But this has a major flaw:
It only returns geometry as a point:
{"type":"FeatureCollection","features":[{"type":"Feature","id":235028771,"geometry":{"type":"Point","coordinates":[27.598497434198464,47.16209573500234],"type":"building"...}}
You can observe that it returns a point even though it is a building.
Is there a way to do this?
The queryRenderedFeatures method DOES return a polygon. Somehow the information reaches the Map object that i query but how can i fetch through an api that info?
What you're trying to do is not possible. Mapbox doesn't provide complete polygon datasets. At best, there are ways of retrieving polygons from vector tilesets (such as query-remote-tiles, which does something similar to TileQuery). But these will only retrieve the part of the polygon within a given vector tile, which may not be what you want. (queryRenderedFeatures has the same issue).

Find adjacent tiles in bing maps

I am grabbing maps from bing using their API:
http://msdn.microsoft.com/en-us/library/ff701724.aspx
The largest tile they can return is 900x834. I need at least double that. Is there an easy way to figure out what the adjacent tiles are for any given zoom level and long/lat for a given resolution.
In other words, given a long,lat, zoom level, and resolution what would be the long lat for the 8 surrounding tiles in the same zoom level and resolution. Or is there a better way to get a large map?
Here's my GET request:
http://dev.virtualearth.net/REST/v1/Imagery/Map/Aerial/#{lat},#{long}/#{rand(19)}?mapSize=900,834&format=png&key=MYKEY
It is not possible to do this without breaking the rules set in the Terms of Use, especially the automation regarding your imagery retrieval (or composition).
See: http://www.microsoft.com/maps/product/terms.html
If you want to do this anyway with maybe a dedicated agreement to proceed (if possible), I would recommend to use mapArea parameters rather than using the lat long of the center, see:
http://msdn.microsoft.com/en-us/library/ff701724.aspx
See an example of mapArea imagery retrieval:
http://dev.virtualearth.net/REST/V1/Imagery/Map/road?mapArea=37.317227,-122.318439,37.939081,-122.194565&ms=500,600&pp=37.869505,-122.2705;35;BK&pp=37.428175,-122.169680;;ST&ml=TrafficFlow&key=BingMapsKey
If you want to access tile url in a supported way, you can use the same imagery service to retrieve metadata that will contain tile url. Tile are based on a quadkey model so you will be able to load the tile nearby your current view.

OpenStreetMap Api call returns empty set

I am trying to call OpenStreetMap API:
http://api.openstreetmap.org/api/0.6/map?bbox=43.65,-79.38,43.66,-79.37
It returns no error, but map is empty:
Do you have any ideas why?
thanks
I think for the given request, the empty dataset delivered is actually the correct response.
The API documentation says api/0.6/map returns
All nodes that are inside a given bounding box and any relations that reference them.
All ways that reference at least one node that is inside a given bounding box, any relations that reference them [the ways], and any
nodes outside the bounding box that the ways may reference.
All relations that reference one of the nodes, ways or relations included due to the above rules. (Does not apply recursively, see
explanation below.)
As far as I can see, your bounding box selects a bit of Antarctica. What data did you expect?
I guess, in OSM, Antarctica is just a way, describing its outline (and maybe some research stations somewhere). If you now ask for an area in the middle of nowhere there, there are no data to get. This is because within your bbox there are no nodes. The way for the outline/area of Antarctica is only fetched if at least one of its nodes lies within your bounding box.
PS: If you want a piece of Toronto (with lots of data), swap longitude and latitude values :)
https://wiki.openstreetmap.org/wiki/Download#Construct_a_URL_for_the_HTTP_API
it says the bounding box can only be 0.5 by 0.5 degrees. it also says you might want to try XAPI for such a large area