# Getting lat/long based on distance travelled along street

 2 1 Hi there! I want to draw a lot of cars moving around on a map. I have the osm data parsed and put into a graph using GraphServer. What I'd like is a function to do is this (in C style pseudocode): ``````Coordinates getCurrentPoint(street,distance_traveled_along_street){ return current_position_in_lat_long; } `````` So basically, I've travelled so many meters along this street, now where am I in lat/long? Obviously this is isn't hard when the map is a grid, but it does seem VERY tricky to me for more complicated road maps. Any ideas of where to begin or other projects that I can leverage? EDIT: A bit more explanation...GraphServer (as mentioned in the comments), just gives me nodes and edges. But the nodes map directly back to the osm nodes and the edges map directly to "ways". So maybe my question is better phrased as...I'm travelling along a way at velocity v, in s seconds, where am I? asked 19 Apr '12, 01:50 Rex 31●1●1●4 accept rate: 0% stephan75 12.5k●4●54●209 I don't know GraphServer, but from a quick googling, it seems GraphServer only deals in nodes and edges, not in real geographical data - so the graph simply does not contain the information you need. Maybe you could explain how you use GraphServer, what information you put into it, and what it does for you? (19 Apr '12, 15:35) sleske I edited the question :) (19 Apr '12, 16:46) Rex

 0 Go through each segment of the street, calculating distance of the line between each pair of nodes (see useful formulas). Consider storing this data for the duration of your program. Go through each segment of the street, subtracting the length of each segment of street from your total, until the remaining distance is less than the length of a street segment, which means you've found the segment of street you're currently in. Calculate your position within that segment of street using the remaining distance, by linearly interpolating between its start and end nodes. answered 20 Apr '12, 18:15 OJW 151●8●8●15 accept rate: 0%
 toggle preview community wiki:

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Question tags:

×598
×19
×1

question asked: 19 Apr '12, 01:50

question was seen: 3,335 times

last updated: 20 Apr '12, 18:15