Hi there. I'm looking to develop a GPS like system for mobile devices (specifically MIDP compatible devices) with a custom map and my own code to draw the route. It won't necessarily be roads, but the inside of a building so I can't exactly utilize a service like Google Maps.
I can't seem to figure out the best logic for how it should determine where to draw to next. I have it set based on coordinates on the screen.. So it has a starting point and an end point. Now whats the best way to determine the points in between? Here was the logic I have been thinking of so far but hopefully you folks can help iron this out and point me in the right direction:
loop through a list of coordinates
test each for lowest distance between these coordinates and startx & starty
set lowest coordinates equal to nextx and nexty
if nextx, nexty = endx, endy
end -> set continueLoop to false
draw line from startx, starty to nextx, nexty
set lastx, lasty equal to nextx, nexty
otherwise inner loop while continueLoop = true
find the next set of coordinates with lowest distance from those to nextx, nexty
set nextx, nexty equal to those
if nextx, nexty = endx, endy
continueLoop = false
drawline from lastx, lasty to nextx, nexty
set nextx, nexty equal to lastx, lasty
I know this won't work because it doesn't account for going the opposite direction, so how could I refine this?