OSM - Find all optional routes in specific bounding-box - openstreetmap

My goal is to get a list of all optional routes in certain area.
I want to use OSM for achieving this data
Route means pair or intersections that it's possible to drive from the first intersection to the second.
In the case at the image:
The optional routes are:
1-2 , 1-4
2-1 , 2-3 , 2-5
3-2 , 3-6
4-1 , 4-5
5-4 , 5-2 , 5-6
6-5 , 6-3
So far I have tried this code in overpass-turbo site:
[bbox:{{bbox}}];
way[highway~"^(residential)$"]->.minor;
node(w.minor)(w.minor);
out;
The output is the intersections, but:
List doesn't contain all the intersections
I need the routes = connection of pairs of intersections

If you're comfortable using Java, consider taking a look at Atlas. Atlas is an in memory representation of OSM data that will allow you to create a graph representing the street network. There is an Atlas API layer for connectivity, routing and spatial searches. For your specific need - there is the concept of a Route - which maintains the OSM Ways and Nodes specifying a path between two Nodes or Ways. There are ways to get the most optimal Route or obtain all possible Routes.
To get started, I recommend the following:
Set up and familiarize yourself with the Atlas project
Extract an OSM or PBF file with the area of interest
Create an Atlas file from the PBF, run applicable routing algorithm
Sample code to load an OSM file:
public class TestAtlasTestRule extends CoreTestRule
{
#TestAtlas(loadFromJosmOsmResource = "yourOsmFile.osm")
private Atlas yourAtlasFile;
public Atlas getAtlasFile()
{
return this.yourAtlasFile;
}
}
Sample code to obtain routes:
// To get the shortest route
final Route shortestRoute = AStarRouter.dijkstra(yourAtlasFile, distanceThreshold).route(startNode, endNode);
// To get all the routes
final Set<Route> allRoutes = AllPathsRouter.allRoutes(startEdge, endEdge, comparatorThatEnforcesRouteOrdering);

Related

OSMNx: How to fetch street network using saved osm xml instead of overpass api call request

I can fetch OSM street network using
G=ox.graph_from_point((lat, lng),custom_filter=road_filter,dist=20,simplify=False,retain_all=True)
The process is very slow if i have to make 1000 of such requests.I was hoping if i can load the saved osm file then query locally for the osm road networks.
In Osmnx, the only way to create a graph from a local .osm formatted XML file is:
graph = osmnx.graph_from_xml(filepath, simplify=False, retain_all=True)
There are not filters as other graph_from_*() functions, but once you got the graph you can query the Geodataframes containing nodes and edges that you get with:
nodes, edges = osmnx.graph_to_gdfs(graph, nodes=True, edges=True)

Using OSRM with big queries?

I am experimenting with table service, the first restriction I thought about is the URL query length, as it work by http get request.
I need to send 5000 location, considering location is 35 characters long as for example:
35.921870470047,31.949649689353226;
thus, I will be sending 175000 character in the url, which is not possible I think for all browsers.
I will pass the result of durations matrix into the vehicle routing problem solver of Google Optimization Tools with the duarion matrix of a 5000 input location.
Here is an example of my query for small number of locations:
http://router.project-osrm.org/table/v1/driving/35.921870470047,31.949649689353226;35.88357925415039,31.974007590177635;35.92055082321167,31.948830365146534
Any advice?

Feed JSON to Nominatim with import.io

Greetings fellow SO users,
I am extracting data with import.io from a site which contains city names. What I want to accomplish is to get the coordinates to each city from Nominatim and finally create/get a JSON response which contains the city name and the corresponding coordinates for each.
So I basically need to use the result from one API as the input for another (Nominatim).
Or in other words: feed a JSON list of city names to OSM's Nominatim and get back the coordinates to each city.
I wonder if this is even possible or what other options I have. Finally this would be used with leaflet to put some markers at a map.
There are tutorials for Nominatim, how to query etc. but only one query at a time. Is it even possible to query a whole list of places?
What you want to achieve in here is what we call Chained APIs. So you will need two APIs, where the input of the second one is the output of the first one.
In this case you will need some custom processing between the two APIs. From the first API you are getting the city name and from here you need to generate a list of URLs in the format http://nominatim.openstreetmap.org/search?q=CITY&format=xml one per each CITY.
After that you can use the Bulk Extract feature in import.io and pass the whole list of URLs to be queried against the API.

pgrouting not find routes

Having in hand the shape of the road and rural roads in the target region, followed the workshop documentation is available in pgrouting the site, I created the required fields, ran the pgr_createTopology, and other verification queries pgr_analyzeGraph and pgr_nodeNetwork, obtaining return "OK" in all of them.
QGIS using the BD Manager, to perform queries can not obtain routes from all nodes to all nodes, just a few return a possible route and only in segments almost completely straight.
I tried using the plugin pgRoutingLayer produced by Anita Graser and Ko Nagase, but the result is identical to direct SQL query.
I am using the pgr_djikstra to locate the route.
Does anyone have any idea what could be wrong? The following image with found and not found route.
Route found
Route not found

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!