java - Shortest path between raw geo coordinates and a node of a graph -


i have implemented simple dijkstra's algorithm finding shortest path on .osm map java.

the pathfinding in graph created .osm file works pretty well. in case user's current location and/or destination not node of graph (just raw coordinates) how 'link' coordinates graph make pathfinding work?

the simple straightforward solution "find nearest current location node , draw straight line" doesn't seem realistic. if have situation on attached picture? (upd) enter image description here

the problem here before start 'smart' pathfinding algorithms (like dijkstra's) 'link' current position graph, dumb formula (a hypotenuse pythagorean theorem) of finding nearest node in terms of geographical coordinates , formula not 'pathinding' - can not take obstacles , types of nodes account.

to paraphrase - how find shortest path between , b if b node in graph, , not node?

have heard of other solutions problem?

the process you're describing "map matching," , uses spatial index find nearest node.

one common approach construct quadtree contains nodes, identify quad contains point, calculate distance point nodes in quad (recognizing longitudinal degrees shorter latitudinal degrees). if there no nodes in quad progressively expand search. there several caveats quadtrees, should @ least started.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -