View Single Post
Posts: 2,006 | Thanked: 3,351 times | Joined on Jun 2010 @ N900: Battery low. N950: torx 4 re-used once and fine; SIM port torn apart
#175
Originally Posted by MartinK View Post
This could be because how the OSM XML is formated. The nodes are ordered by id not by latitude or longitude and the id don't go in a complete sequence, so they cant be used as a list index. The nodes also have no info about which ways they are part of. Ways on the other hand have have just a sequence of node ids.
I see...

Originally Posted by MartinK View Post
There is also a lot of irrelevant information like usernames and timestamps.
There are neither user-names nor timestamps. There are attributions, postcodes, speed restrictions and a lot of other information which might be irrelevant.

Originally Posted by MartinK View Post
I think that with this structure, all operations needed for routing, like computing distance between nodes or finding which way is a node part of would be very, very slow.
Well... If you have small XML file, it will not be that slow.

Originally Posted by MartinK View Post
My guess is, that in the binary formats:
  • they sort the nodes and ways, so that near nodes/ways can be quickly found
  • nodes have info about which ways they are part of
  • ways have complete info about their nodes
  • every item has some global id, so you can just jump on a position in the file to get relevant data
  • all unneeded items are removed
Then use OSM Binary Format.
Originally Posted by MartinK View Post
Also, country sized extracts seem to have 100MB+, for example the whole UK has 218MB.
Oh, I see. But nobody is going to travel through the whole UK. Most people need just one small region/city.

Originally Posted by MartinK View Post
If I understand this correctly:
  • find nearest node that is a part of a route
  • follow the route in both directions
  • on both ends, choose the node, that is closest to the destination
  • then this for all ways joining the segment between the chosen node and closest one
  • do this for say, 10 steps maximum
  • automatically update as the current position changes
Well, this could theoretically get you to in the direction to your destination, by any means possible. At least, it could be quite an adventure.
Word "route" has too ambiguous meaning. It's often used for complete zig-zag line from start to destination, and this algorithm doesn't have such a line.
  • find nearest node that is a part of a way (road, highway, footpath) - it will be "current node" (yes, it will be time-consuming to look through all this list of nodes in a loop, but you can stop at the first node-part-of-a-way which is close enough (say, not more than two meters from real position) instead of looking for the nearest one);
  • follow the way in both directions; on both ends, choose the node, that is closest to the "current node"; in fact, you don't need to do any choosing: just "current node".nextSibling() and "current node".previousSibling();
  • then this for all ways referencing this node
  • take all the next/previous nodes found in above-described steps and compare their coordinates with coordinates of "current node"; it gives vectors of directions; multiply each of this vectors (length of each vector should be equal to 1) with needed vector (beeline vector from current node to destination); the largest of the results corresponds to the best choice, and negative results correspond to vectors leading away from destination;
  • automatically update as the current position changes


Originally Posted by MartinK View Post
There also seems to be a binary OSM API for mobile devices, that accepts bounding box input and also supports diffs.
Very well, try it!

There is an application compiled for Maemo 4 and Windows CE which uses OSM Binary Protocol:
http://sourceforge.net/projects/roadmap/files/

You can have a look at its code.

EDIT: Adding a picture
Attached Images
 

Last edited by Wikiwide; 2010-09-05 at 01:48. Reason: Adding a picture
 

The Following User Says Thank You to Wikiwide For This Useful Post: