user1066429
user1066429

Reputation: 57

Custom routing on google map

I have a Google map area for which routing is undefined. It is the campus for my university. I want to some two more buildings to it and some polylines to define the roads as the roads are not shown on the map. Then I will apply A* algorithm to find the shortest route between one polyline to the other. The map will be available to an android application for mobile. In its basic state the application updates the location of the user. The user can request to go to the faculty of engineering for example. Now how will I know where he is, i mean what is the source for the route, the closest polyline? Is this the way things are done? Thank you.

Upvotes: 4

Views: 1788

Answers (3)

Graham Asher
Graham Asher

Reputation: 1780

  1. Use OpenStreetMap data; you can join OSM as a contributor and add buildings, roads and other things to the map. OpenStreetMap is a sort of Wikipedia but with maps, not encyclopaedia articles.

  2. Download and process the OpenStreetMap data for your campus: get all the polylines usable as routes; sort their points; identify points common to more than one polyline - they are nodes; create a directed graph of arcs joining these nodes.

  3. Implement the A* algorithm using the directed graph. A* is definitely the best algorithm to use; fast, correct and well documented.

  4. Use a GPS device (on which your code is running) to find out where your user is. GPS gives positions in lat/long; OpenStreetMap data is also in lat/long; so that should work fine.

This will naturally involve some research and hard work. I guarantee it will do what you want, because I have done this myself (commercially - I won't link to my product because I have been rapped on the knuckles for that; but I naturally claim that doing something commercially imposes a certain discipline). There is plenty of open-source software to help with these things. In particular, the A* algorithm is explained very well on Wikipedia.

Upvotes: 2

zeacuss
zeacuss

Reputation: 2623

If your problem is to find the location of the user, then you can use GPS. About getting the shortest route: A* is faster than dijkestra, so it is a good choice,but getting the result probably needs to be from the nodes of the poly lines, not from one poly line to the other

Upvotes: 0

Cybercartel
Cybercartel

Reputation: 12592

I don't think A* algorithm is the right algorithm. For shortest path dijkestra algorithm is better. According to wikipedia A* is only faster but have the same result. Everthing else seems very reasonable.

Upvotes: 0

Related Questions