I have a problem with OSRM and leaflet, i need to create a route.
What the user do :
select (multiple or no) any itinerary (polyline) displayed on map
when they are selected the user can create the route
and here, my problem, how can i create a route from coordinates of they polilynes ?
i have tried a lot of things, but nothing worked, with osrm we need to add waypoints, but my coordinates are note waypoints and they are many many many !
how can i proceed ? recuce the array of coords ? but i need to be sure that the route use the correct itinerary :/
Related
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);
While fetching a driving route from OSRM, is it possible to fetch the names of the roads that feed into that path (so crossings and side roads)? If so, how can this be done?
Unfortunately you can only retrieve the names of the roads that are part of the route. This information is available if you pass the option steps=true.
The .routes[].legs[].steps[] object (RouteStep) has a property name that contains the street name.
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
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!
I am using CSMapAnnotation classes for different purposes. Now I have to show route between two locations. I do have latitude and longitude for both of the locations.
Can any one please help the best way to achieve that ?
You can use this example:
http://blog.kadirpekel.com/2010/05/30/drawing_routes_onto_mkmapview_using_unofficial_google_maps_directions_api/
It will call the routing api and parse the result.
Then a new layer is added above the map with the route between A and B.