Welcome: Distance Calculator
Welcome: Distance Calculator
Distance Calculator
By: Meharaj &
Contents
Abstract Introduction Requirement Specification Data flow diagram Project Task Dijkstra's algorithm Google Distance Matrix
Abstract
Distance Calculator 1 is a Google Map API based Program which accepts Source and
Destination places from where to where he wants to go and returns user the correct solution , i.e. by
Introduction
Google Distance Matrix API
The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
Introduction(cont.)
Dijkstra's algorithm
For a given source vertex (node) in the graph, the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. It can also be used for finding costs of shortest paths from a single vertex to a single destination vertex by stopping the algorithm once the shortest path to the destination vertex has been determined.
Requirement Specification
Internet connection : 1mbps JavaScript Enabled Browser : Any
Project task
To get input cities from the user. Sending request to the Google server. Getting the responses and storing them into the adjacency matrix. Using dijkstras algorithm finding shortest path between source and destination cities. And presenting the result to user.
Dijkstra's algorithm
// Let V be the set of all vertices in G, and s the start vertex. for(each vertex v){ currentDistance(s-v) = ; predecessor(v) = undefined; For each vertex, the algorithm keeps track of its } current estimated shortest distance from the starting vertex and its predecessor on the currentDistance(s-s) = 0; current path T = V; while(T ){ v = a vertex in T with minimal currentDistance from s; T= T {v}; for(each vertex u adjacent to v and in T){ if(currentDistance(s-u) > currentDistance(s-v) + weight(edge(vu)){ currentDistance(s-u) = currentDistance(s-v) + weight(edge(vu)); predecessor(u) = v; } }}
Dijkstra's algorithm(cont.)
Example
Tracing Dijkstras algorithm starting at vertex B:
Optional parameters:
mode specifies the mode of transport to use when calculating
directions. Valid value are:
driving (default) indicates standard driving directions using the road network. walking requests walking directions via pedestrian paths & sidewalks (where available). bicycling requests bicycling directions via bicycle paths & preferred streets (currently only available in the US and some Canadian cities).
References
https://developers.google.com/maps/documentation/distance matrix/#DistanceMatrixRequests http://www.w3schools.com/googleAPI