Hi all, two days ago I asked the question entitled: "Data of routes characteristics (nodes, orientation) of a pedestrian walking path". I had no answers, but only a comment, useful and I thanks, but I would like to better formulate the question. I need to know the direction (orientation towards the north) of a straight road, of which you know the street, between two known addresses (e.g. address with house number). I need to know the value with the best possible accuracy. I would like to ask if it is possible to know the value of the direction, that I suppose is stored, by asking a question to the OSM database without calculating the value through the coordinates of the two points after reading them on the display. As you know it's difficult to position the points on the display very well and this can cause errors Thank you very much asked 23 Feb '20, 20:51 SergioV |
Thanks for the answers. So if I need to know the direction of a stretch of road accurately I have to measure the coordinates of two points belonging to the stretch of road very accurately. I can't read the coordinates of the points on the display where the OSM is represented because it's not an accurate method, unless I zoom in on the map presentation answered 25 Feb '20, 00:03 SergioV Yes. Drawing a map always incurs a loss of precision. Just how big that loss is depends on many factors, including resolution and zoom level, but also the particular map style and parameters used for drawing (for example, some maps might simplify geometries before drawing). To get best results you would first have to retrieve the data behind the map, e.g. through services like Nominatim or Overpass, and then base your computation on that.
(25 Feb '20, 00:09)
Frederik Ramm ♦
|
In the OSM database, ways (which are used to model streets among others) are mostly a list of nodes. Only the node have coordinates. See the OSM wiki for more details about the OSM.database model. So no, the direction of the ways is not stored. And they are usually not straight if composed of more than two nodes. I guess that routers (like graphhopper, OSRM, etc, see the other question) will provide the direction of each segment of a calculated route between two points. answered 24 Feb '20, 23:24 H_mlet |
Assuming that:
Then the steps required would be the following:
This will yield precise results independent of display. However, it will give you the angle between the two address points which is not necessarily the angle of the street. If you want to be super precise, you will need to identify the street (possibly through an additional geocoding request) and retrieve its geometry, then drop the perpendicular from each of the address points to the street geometry, and use the resulting points that lie on the street for the angle calculation. This will be harder if for any reason the street should consist of multiple parts in OSM. There is no web service that would do this work for you. answered 23 Feb '20, 21:00 Frederik Ramm ♦ |