Getting routes on openstreetmaps using OSRM - openstreetmap

I've been trying to get a list of co-ordinates in a route from point A to B using OSRM with the following request:
GET http://router.project-osrm.org/viaroute?hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760
However, on opening the url, i find the 'via_points' tag containing only two co-ordinates. Surely, that can't be the entire route? Anything I'm missing here? Is there any other way of generating the list of route co-ordinates with OSRM? Thanks

The route is contained in the route_geometry object. It is an encoded polyline. If you don't want to uncompress it yourself you can disable compression via compression=false:
http://router.project-osrm.org/viaroute?compression=false&hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760
Not sure what the via_points contains. OSRM's documentation seems to be outdated. Maybe they are just your start and end points snapped to the nearest road or something similar.

Related

Extrapolate Coordinates form Leaflet map

I'm planning a climbing trip and I wanted to retrieve the climbing locations from a leaflet map.
I thought I could use chromedriver and selenium to get the information I wanted but I'm having difficulty scanning through all markers since I can't understand where all the informations are stored.
Could someone guide me through how I could get the information? (also without using selenium)
The map in question is: https://www.climbingsardinia.com/topos/maps/
Thank you in advance.
in that page you will see a global variable called cttm_markers, it contains all markers informations and relative coordinates.
For example, cttm_markers[0][[0].additionalData.title evaluates "M.te Arci – Trebina Longa".Further, cttm_markers[0][[0]._latlng is an object {lat,lng} that contains coordinates.
Try to open console and paste this: JSON.stringify(cttm_markers[0].map(c=>({title:c.additionalData.title,latlng:c._latlng}))), it will print a json.
One way to do it is to get some information on one of the markers and use this to search the request reponses made by the page (you can do this in the debug tools, usually opened with F12). One of the markers for example reveals the location "Grighini". The base request redirects to (in my case) https://www.climbingsardinia.com/topos/maps/?doing_wp_cron=1651158093.0027918815612792968750
Searching the response, reveals that in line 1908 there's the string "Grighini". This line contains a serialized JSON array, containing the markers.

How to add maps to one simulator?

I am using one simulator and wanted to add my own maps. So I looked into this website https://mygeodata.cloud/ which can provide me with the wkt files of maps.
The problem is I am not able to get these to work, can someone provide some details on how to add a town's map with maybe bus routes etc to ONE Simulator?
The error I'm getting is "SimMap is not fully connected. Only 1057 out of 1113 map nodes can be reached from Nt2#(-1.15,52.95). E.g. Nt2#(-1.14,52.95) can't be reached"
The default roads.wtk files have linestrings like this
LINESTRING (2551683.6644129306 6674375.029443317, 2551528.069902012
6674337.650863852)
While my linestrings of Nottingham,England are this
LINESTRING (-1.1525824 52.9518235,-1.1524917 52.9517354,-1.1519975 >
52.9511418,-1.1517313 52.9508255)
It seems that your input map has around 50 nodes that can not be reached from other map nodes. The ONE Simulator needs to have the map fully connected (i.e., all nodes need to be reachable). Check out the map source (e.g., using OpenJUMP) and look for nodes or map segments that are not connected to each other and delete them or connect them with new line segments. The error message gives you a hint where to look at.
For an example on how to add bus routes, check out the Helsinki map and the tram/bus route files: https://github.com/akeranen/the-one/tree/master/data
that is because there is a broken node there should be a check again for the existing map input because some moves do not want any broken lines there can make messages from open strapmaps then edit using open jump

Determining highway direction

I was wondering if there is a way to get the highway direction of the route.
To be more specific, I am interested in routes on interstate highways in the United States only.
I'll give an example:
Interstate I45 is a north-south highway. When the route is returned, is there a way to know which "direction lane" the route is on?
The problem I'm trying to solve is accessing the rest ares like the one shown on the image here. As you can see, these are two rest areas, each accessible from one direction of the highway.
I would like to display only those accessible from the direction the user is on. I have all the data needed, including if the rest area is on the North/South/East/West direction and I only need the highway direction the route is on.
For obvious reasons, I would like to avoid manually checking if the route just appears to be going northwards.
I checked if this is possible via graphhopper, but it only gives the highway name, without direction. Is it possible to achieve this via Skobbler?
If you are using the TTS instructions (text-to-speech) then in the advice instructions & audio advices you will also receive the "orientation" (coded as a $orientation in the audio config files) - indicating the direction you are driving on a particular highway (south/north, etc.).
The trickier part is that you would have to parse the text instruction to get this information as it's not returned in a separate field (let me know in a comment if this was helpful).
I do not fully understand the original problem but as GraphHopper also returns the geometry for every instruction you should be able to calculate the orientation roughly but easily.
Another more complex approach would be to have a predefined name set associated with the geometry and use the map matching component to find out which highway parts are used in a route.
For obvious reasons,
which obvious reasons? That it is not really going norht south?
Or if something is not possible you always can modify in the code as it is open source or provide a pull request to merge it into the public release (if useful for others) and make it available for the Directions API too.
According to the OSM wiki page Highway Directions In The United States, directions of ways are supposed to be modeled as relation membership roles.
For example, I 75 way 173483918 is a member of the relation 332618 named "I 75 (TN northbound)" with role=north, so it's direction is "north".
The opposite way 173483897 is a member of the relation 332624 named "I 75 (TN southbound)" as role "south".
See more details on the wiki page. Don't know how well established that tagging scheme is, also don't know about router support (Telenav (Scout) seem to be involved in this who now own Skobbler).

Getting distance between 2 markers

I would like to get the distance between 2 markers but not as a direct line, more as a real path like it goes in this plugin -
https://github.com/perliedman/leaflet-routing-machine
I didn't find anything about using this plugin in the directive: angular-leaflet-directive,
if someone can guide how to make it done, it would be very appreciated.
thanks!
I am not sure if you specifically want to use leaflet routing machine to get distances... but if you do, maybe this info can get you started:
Set up a route on your map based on this example by the leaflet routing machine author:
https://www.liedman.net/leaflet-routing-machine/tutorials/interaction/
If you look at that example, there is an array called routes. Each route has some basic statistics associated with it, generated by OSRM. You can pull them by calling for example:
routes[0].summary.totalDistance
or
routes[0].summary.totalTime
Then you can do whatever you want with them. If you dig through the code on GitHub you can see more about how the data are moved around within the plugin and why the array is arranged that way:
https://unpkg.com/leaflet-routing-machine#3.2.12/dist/leaflet-routing-machine.js

How to draw route on map with KMLParser

I am parsing a kml file using KMLParser in my application. When i open the kml file in google map it shows me the route with annotations & overlay's. My query is
1) Is it possible to get the route data from kml to draw the route on map
2) If not how can i achieve route drawing from kml file
Any suggestion or hint will be helpful.
I am not sure if you can get the route data from the KML-file using KMLParser, as I'm not sure what features that parser provides. An alternative to using KMLParser would be to simply parse the KML-file yourself, using for example KissXML och GDataXML. If you only need the route information from the KML-file, using a plain XML-parser might be simpler.
You need to parse the data and then translate it into something you can draw on the map, like CLLocationCoordinate2D. Once you have your data as an array of CLLocationCoordinate2D-coordinates, you can follow this tutorial for learning how to draw a line on a map: http://www.raywenderlich.com/30001/overlay-images-and-overlay-views-with-mapkit-tutorial Specifically the section "I Walk The Line – MKPolyline".
Good luck!