# Web Based GIS Route Finder System

## Web Based GIS Route Finder System

**Web Based GIS Route Finder System M.Tech Project Report by Akhilesh Kumar Singh 08305020 Under the guidance of Prof. N. L. Sarda Department of Computer Science and Engineering Indian Institute Of Technology, Bombay 2010**

INDIAN INSTITUTE OF TECHNOLOGY BOMBAY CERTIFICATE OF COURSE WORK This is to certify that Mr. Akhilesh Kumar Singh was admitted to the candidacy of the M.Tech. Degree and has successfully completed all the courses required for the M.Tech. Programme. The details of the course work done are given below. Sl. No.

Course No. Course Name Credits Semester 1 (July 2008 – November 2008) 1 CS 641 Advance Computer Networks 6 2 CS 649 Network Security 6 3 CS 653 Mobile Computing 6 4 CS 699 Software Lab 8 Semester 2 (January 2009 – April 2009) 5 HS 625 Philosophy of Education 6 6 CS 647 Advance Wireless System 6 7 CS 670 IT Project Management 6 8 CS 680 Quality of Service in Networks 6 9 CS 682 Software Engineering 6 10 CS 694 Seminar 4 11 HS 699 Communication and Presentation Skills (P/NP) 4 Semester 3 (July 2009 – November 2009) 12 CS 445 Management Information System 6 13 CS 683 Advance Computer Architecture 6 M.Tech.

Project 14 CS 797 M.Tech. Project Stage I (October 2009) 50 15 CS 798 M.Tech. Project Stage II (June 2009) 40 I.I.T. Bombay Dy. Registrar (Academic)

Abstract The rapid rise in population along with increased urban land use has generated considerable travel demand as well as numerous transport problems. The congestion, safety and environmental problems increased to such an extent that it has become increasingly difficult to navigate due to the combined effects of rapid motorization and urbanization. With the development of Intelligent Transport System (ITS) and Geographic Information System (GIS), the increasingly intensive demand of route guidance system in real time has coincided with the increasing growth of roads in real world. A route guidance system helps to tackle many of the transportation problems by minimizing congestion and ensuring uniform utilization of the road network.

For this purpose modeling of real road network into digital map format is necessary that requires large amount of preprocessing time and human effort.

The main impetus behind this project is to develop a Web Based GIS Route Finder System that not only models and process the real road network to digital format on the fly but also provides users with different route finder options. The main aim of the developed system is to minimize the number of re-computations for finding shortest route and alternate route. This leads to less memory consumption and less wastage of resources resulting in minimized response time. i

List of Abbreviations Used Sl. No. Abbreviation Full Form 1 ITS Intelligent Transport System 2 TIS Traveler Information System 3 ATIS Advance Traveler Information System 4 RGIS Route Guidance Information System 5 OpR Optimal Route 6 TdOpR Traffic Dependent Optimal Route 7 DP Dynamic Programming 8 GIS Geographic Information System 9 WMS Web Map Service 10 IDE Integrated Development Environment 11 JVM Java Virtual Machine 12 JDK Java Development Kit 13 LOH Level of Hierarchy 14 P2P Point to Point 15 A2A All to All ii

List of Tables Sl. No. Table No. Content Page No. 1 2.1.3 Graph Notations 3 2 2.2.1 Dijkstra pseudo code 4 3 2.2.2 Floyd Warshall pseudo code 5 4 2.2.3 A* pseudo code 7 5 3.1 Pseudo Code for Shortest Route Finder 13 6 3.2 Pseudo Code for Alternate Route Finder 14 7 3.3.1 Pseudo Code for Facility Based Route Finder via Single Facility 16 8 3.3.2 Pseudo Code for Facility Based Route Finder via List of Facilities (ID Known) 16 9 3.3.3 Pseudo Code for Facility Based Route Finder via List of Facilities (ID Unknown) 17 10 3.4 Pseudo Code for Hierarchical Route Finder 19 11 3.5 Pseudo Code for Multimodal Route Finder 20 12 4.2 (A) Normal matrix complexity vs.

Sparse matrix complexity 22 13 4.2 (B) Result of comparing FW, Dijkstra and A-star (A*) 23 iii

List of Figures Figure No. Content Page No. 3.1 Web Based GIS Route Finder System 11 3.2 Data Modal of System 12 3.3 Different Level of Hierarchies 18 4.1 Normal matrix complexity vs. Sparse matrix complexity 22 4.2 Time complexity in normal vs. our approach 25 4.3 Space complexity in normal vs. our approach 25 1 Sample Dataset: Hyderabad Road data 31 2 Home Page of System Developed 32 3 Shape File Menu 33 4 Route Finder Menu 33 5 Search Menu 33 6 Misc Menu 33 7 LOH 1 view 34 8 LOH 2 view 35 9 LOH 3 view 35 10 Multimodal view 36 iv

CONTENTS Sl. No. Content Page No.

i Abstract i ii List of Abbreviations used ii Iii List of Tables iii Iv List of Figures iv 1 Introduction & Motivation 1 2 Background Study and Literature Survey 2 2.1 Basic Concepts 2 2.1.1 Intelligent Transport System 2 2.1.2 Route Guidance 2 2.1.3 Network Definition 3 2.2 Search Techniques 4 2.2.1 Dijkstra Algorithm 4 2.2.2 Floyd-Warshall Algorithm 5 2.2.3 A* Search Algorithm 6 2.3 Classification of Problem 8 2.3.1 Optimal Route Problem 8 2.3.2 Traffic-dependent Optimal Route Problem 8 2.4 Related Works 8 2.4.1 Google Maps 9 2.4.2 Mumbai Navigator 9 2.4.3 MapmyIndia 9 2.4.4 OpenStreetMap 9 3 Implementation 10 3.1 Shortest Route Finder 12 3.2 Alternate Route Finder 14 3.3 Facility Based Route Finder 15 3.4 Hierarchical Route Finder 17 3.5 Multi Modal Route Finder 19 4 Experimentation 22 4.1 Experimental Results 22

**5 Conclusion and Future Work 27 6 References 29 Appendix A Sample Road Network : Hyderabad Road Data 31 B Home Page of System Developed 32 C Different Menu Options of System Developed 33 D Different Level Of Hierarchies of Road Network 34 E Multimodal view of Road Network 36 Acknowledgement 37**

1 Chapter-1 Introduction and Motivation The goal of Intelligent Transport System (ITS) is to apply Information Technology concepts, Communication Networks, Internet and other technologies to Transport Management System (TMS) to improve travel time, safety, reliability, passenger convenience and to mitigate traffic congestion.

Continuous efforts have taken place to resolve the problems related to road and traffic management system. Simultaneously the improvement and progress in Information Technology has also speedup the deployment of various systems of Intelligent Transport System. Continuous rapid growth in the number of vehicles and roads lead to recursive demand of better search techniques and frameworks to tackle not only the social and economic impact of deploying ITS but also the environmental impact. A GIS can help visualize and communicate the effects of roads on their environment. Merging of GIS in TMS comes from the problem caused by traffic congestion since, roads are part of the infrastructure that makes up the spinal cord of modern society, but these can just easily turn into bottlenecks therefore route planning is one of the most popular applications within TMS and planning it in advance of a journey is one way to enhance the efficiency of TMS.

But, modeling large real road network into database format requires great amount of preprocessing time, human effort and manual working. In this project we introduce a new way of modeling and processing of real road network into database format. For the purpose, we have developed a Web Based GIS Route Finder System that helps one to figure out how best to get where one wants to go. It helps us to find better paths to travel from source to destination. The better route is defined over set of constraints considered by user during route selection process. The main aim of Web Based GIS Route Finder System is not only to plan a shortest route between source „s‟ and destination „t‟ but also to plan an alternate or next available shortest route when an edge breaks or gets congested in st with minimized number of re-computations of programs.

The system also provides different route finder options like shortest path finder, alternate path finder, facility based path finder, hierarchical path finder, top-k shortest path finder and multimodal path finder with the help of Java programs, PostGIS database and Geoserver.

2 Chapter-2 Background Study and Literature Work 2.1 Basic Concepts 2.1.1 Intelligent Transport System (ITS) To understand fully about the advantage and benefit of search techniques, we must first understand the commercial environment where these techniques are applied. Intelligent Transport Systems (ITS) are those that utilize the technologies and engineering concepts to enhance the capabilities of transportation system. Many route finding systems are in development worldwide. It is the name given to the application of computer and communications technologies to manage transport problems.

In a rapidly changing society, the emphasis on road technology improvements to assist in road management has been identified. As ITS technologies are advancing, they have enabled the collection of data or intelligence which provides relevant and timely information to road managers and users. ITS basically fall into two main categories, centralized and de-centralized systems [6]. Centralized ITS are linked to an information center which collects and processes road and traffic condition and provide route guidance to a driver on request.

De-centralized ITS on other hand offers information computed by individual driver on board using local information sources. Such a system contains road and traffic information on optical devices with GPS facility enabled. 2.1.2 Route Guidance Route Guidance is an essential component of Intelligent Transport System (ITS) and Traveler Information System (TIS) which provides road condition, traffic information and travel recommendations to driver to help them make better travel decisions. Route guidance can be provided to a driver on demand by information center (Centralized ITS) or can be computed by individual driver (De-centralized System).

Route Guidance can be divided into following major categories of guidance, Descriptive or Prescriptive, Static or Dynamic, Reactive or Predictive and System optimal or User optimal [9].

Route Guidance Information System (RGIS) take help of route guidance that can provide guidance to all the drivers at the same time or can provide guidance to an individual driver based on the road network conditions.

3 2.1.3 Network Definition Following are some notations that will be followed in rest of the project report. Table 2.1.3 Graph Notations 1 Sl. No. Notation Used Description 1 G=(V,E) Labeled Directed Graph (G), with n vertices and m edges. 2 V:{V1,V2...VnumVertices} The set of vertices represents intersection or entry and exit of the road in road network 3 numVertices Represents the total number of vertices 4 E:{E1,E2...EnumVertices} The Set of edges is a set of pairs (Vi Vj) representing a road segment between two vertices where i, j belongs to set {0, 1, ..., numVertices} 5 Cw(u,v) The Cost function associating a cost with edge.

Cost function may be function of distance, traffic amount or road congestion and speed or time.

6 Si Represents the set of successors of ith vertices. 7 Pi Represents the set of predecessors of ith vertices. 8 Parenti Represents the parent vertices of ith vertices. 9 d[v] Represents the cost from source (s) to any vertices (v) 10 g(v) Represents the cost of path from source (s) to current node (v) 11 h(v) Represents the heuristic function (h) from vertices (v) to goal node (t) 12 S(u,v) Represents the shortest path between vertices u and v 13 A(u,v) Represents the alternate path when an edge is broken or congested in shortest path, S(u,v) 14 F(u,v) Represents the shortest path, S(u,v) that passes via single or list of facilities (F) 15 MM(u,v) Represents the multi modal path between vertices u and vertices v 16 LOH1 Represents the Level of Hierarchy 1 17 LOH2 Represents the Level of Hierarchy 2 18 LOH3 Represents the Level of Hierarchy 3

4 2.2. Search Techniques 2.2.1 Dijkstra Algorithm Dijkstra algorithm is single source shortest path algorithm i.e. in one execution of the algorithm it gives shortest path to all vertices from single source vertex. The algorithm works from a source (s) by computing for each vertex v pertaining to V the cost d[v] of the shortest path found so far between s and v. Initially this value is set to 0 for the source vertex s (d[s]=0), and infinity for all other vertices, representing the fact that we do not know any path leading to those vertices (d[v]=∞ for every v in V, except s). When the algorithm finishes, d[v] should be the cost of the shortest path from s to v (or infinity, if no such path exists).

The basic operation of Dijkstra's algorithm rests on the essence of DP and is named “Edge Relaxation”. Let‟s suppose that we are looking for the shortest path that goes from s to v. If we know the shortest path from s to all possible u‟s connected to v and if there are edges from those u‟s to v, then the shortest known path from s to u (d[u]) can be obtained through a path (the best path) from s to v by adding edge (u,v) at the end. This path will have length d[u]+w(u,v). If this is less than the current d[v], we can replace the current value of d[v] with the new value. Edge relaxation is applied until all values d[v] represent the cost of the shortest path from s to v.

The algorithm is organized so that each edge (u,v) is relaxed only once, when d[u] has reached its final value.

The algorithm maintains two sets of vertices S and Q. Set S contains all vertices for which we know that the value d[v] is already the cost of the shortest path and set Q contains all other vertices. Set S initially starts empty, and in each step one vertex is moved from Q to S. This vertex is chosen as the vertex with lowest value of d[u]. When a vertex u is moved to S, the algorithm relaxes every outgoing edge (u,v). Table 2.2.1 Dijkstra Pseudo Code Dijkstra’s (G,w,s) Pseudo Code // G is graph, w is weight and s is source. A Predecessor vector is the most efficient representation of the final tree.

1 { 2 initialize d(u) for all u to infinity 3 initialize d(r) to 0 4 initialize Q with all u using d(u) as keys 5 while (Q is not empty) Q.extractMin() 8 for each vertex v that is adjacent to u (i.e. u v)

**5 2.2.2 Floyd Warshall Algorithm Floyd warshall algorithm is all pair shortest path algorithm i.e. In one execution of the algorithm, it gives shortest path between each and every vertex. The Floyd-Warshall algorithm is based on the following observation. Under our assumption that the vertices of G are V = {1, 2 , n}, let us consider a subset {1, 2 , k} of vertices for some k. **

For any pair of vertices i, j V, consider all paths from i to j whose intermediate vertices are all drawn from {1, 2 , k}, and let p be a minimum-weight path from among them. (Path p is simple.) The Floyd-Warshall algorithm exploits a relationship between path p and shortest paths from i to j with all intermediate vertices in the set {1, 2 , k - 1}. The relationship depends on whether or not k is an intermediate vertex of path p.

If k is not an intermediate vertex of path p, then all intermediate vertices of path p are in the set {1, 2 , k - 1}. Thus, a shortest path from vertex i to vertex j with all intermediate vertices in the set {1, 2 , k - 1} is also a shortest path from i to j with all intermediate vertices in the set {1, 2 , k}. If k is an intermediate vertex of path p, then we break p down into i p1 kp2 j p1 is a shortest path from i to k with all intermediate vertices in the set {1, 2 , k}. Because vertex k is not an intermediate vertex of path p1, we see that p1 is a shortest path from i to k with all intermediate vertices in the set {1, 2 , k - 1}.

Similarly, p2 is a shortest path from vertex k to vertex j with all intermediate vertices in the set {1, 2 , k - 1}. Table 2.2.2 Floyd Warshall Pseudo Code 9 { 10 if d(v) > d(u) + w(u,v) 11 { 12 d(v) = d(u) + w(u,v) 13 p(v) = u 14 } 15 } 16 } 17 return p 18 } Floyd Warshall (W) Pseudo Code // W is weight matrix, initially adjacency matrix rows (W) 3 D(0) = W 4 for k = 1 to n 5 {

6 2.2.3 A* Search Algorithm The search techniques discussed so far does not take into account heuristic approach. For a real time road network, the graph contains thousands of numbers of nodes an it is not posible to traverse through each node to find the optimal route. So, we need some Search heuristic based approach. A-star (A*) falls into such category. When the underlying network is euclidean or approximately euclidean like road network then it is possible to improve the average case run time of non heuristic based search algo. The average case run time complexity becomes worse when the topology of road network changes frequnetly.

Thus, there is an important necessity of heuristic based search approach.

The A* algorithm by Hart and Nilsson [8] formalized the concept of integrating a heuristic into a search procedure. Instead of choosing the next node to label permanently as that with the least cost (as measured from the start node), the choice of node is based on the cost from the start node plus an estimate of proximity to the destination (a heuristic estimate) [11]. This algorithm places more importance on paths leading towards t than paths moving away from t In essence the A* algorithm combines two pieces of information: The original distance from source „s‟ to current node , and An estimate of the distance from a current node of the search tree to the destination node „t‟ Thus, f (i)=g(i)+h(i) Where, h(i) is known as „evaluation function‟.

The closer is the estimation of h(i) the better is the quality of A* search. Hence, merit of A* depends highly on evaluation function h(i). 6 for i = 1 to n 7 { 8 for j = 1 to n 9 { 10 di,j (k) = min (di,j (k-1) , di,k (k-1) + dk,j (k-1) 11 ) 12 } 13 } 14 return D(n) 15 }

7 Table 2.2.3 A* Pseudo Code A* Pseudo Code /* a closed list containing all the nodes fully explored, and an open list containing all the nodes currently working on */ 1 { 2 create the open list of nodes, initially containing only our starting node 3 create the closed list of nodes, initially empty 4 while (we have not reached our goal) 5 { 6 consider the best node in the open list (the node with the lowest f value) 7 if (this node is the goal) 8 { 9 then we're done 10 } 11 else 12 { 13 move the current node to the closed list and consider all of its neighbors 14 for (each neighbor) 15 { 16 if (this neighbor is in the closed list and our current g value is lower) 17 { 18 update the neighbor with the new, lower, g value 19 change the neighbor's parent to our current node 20 } 21 else if (this neighbor is in open list and our current g value is lower) 22 { 23 update the neighbor with the new, lower, g value 24 change the neighbor's parent to our current node 25 } 26 else this neighbor is not in either the open or closed list 27 { 28 add the neighbor to the open list and set its g value 29 } 30 } 31 } 32 } 33 }

8 2.3. Classification of Problem 2.3.1 Optimal Route Problem Optimal Route (OpR) can be defined as the shortest path on a directed graph. Using our network notation, given two distinguished vertices source „u‟ and destination „v‟, the optimal path P(u,v) can be defined as the path in G from „u‟ to „v‟ with minimum cost. If the cost is some static parameter such as distance or number of traffic signals then the optimal route problem can be formulated and solved efficiently using traditional search algorithms but if the cost is dynamic parameter and changes frequently then we need to employ some other approach to avoid running search algorithm repeatedly.

One of the major drawbacks using static cost parameter is that they employ static cartography and are unable to provide real time information on the status of the traffic network thus unable to reflect time-dependent changes in the network. Hence these systems are primarily used for pre-trip planning and not within trip guidance [9]. 2.3.2 Traffic Dependent Optimal Route Problem Traditional optimal route problem do not consider the real time traffic condition and hence cannot be used within trip guidance [9]. In Traffic-Dependent Optimal Route Problem (TdOpR) cost is not only based on the static parameter of the edge but also on the amount of traffic on that edge.

Thus, travel time is a function not of the edge alone, but also on the amount of traffic measured by the number of vehicles on that edge.

The optimal route P(u,v) can be defined as the path in graph G from source „u‟ to destination „v‟ with minimal cost that involves an estimate of traffic. The optimal route in this case may be dependent on traffic in two ways: An estimate of the traffic based on the historical data, and An estimate of the current state of traffic. Thus, the amount of traffic on each road segment at the time it will be traversed is computed from combination of the amount of traffic on each road segment based on historical data and the amount of traffic on each road segment measured in present.[9] 2.4. Related Works Many prior works have been done related to hierarchical routing where either traffic networks are divided into several smaller and less complex networks by introducing a hierarchy or the given road network is divided into multiple-layer hierarchy.

Algorithms based on the concept of hierarchical abstraction make use of the knowledge about the road network to reduce search and provide near-optimal solutions. An alternate approach to forming multiple levels of abstraction for route finding was proposed by Timpf et al.[16]. They proposed a conceptual model with three levels of abstraction named planning, instructional and driver levels based on human spatial

9 reasoning. In this approach, an object may be present in all the three levels but with different levels of detail. In our project we have divided road network into three levels of specification ranging from highways to mini roads. There are many map services that employs different concepts and techniques for route finding and trip planning. Some of them are as follows: 2.4.1 Google Maps (formerly Google Local) Google Maps is a web mapping service application and technology provided by Google. It offers street maps, a route planner for traveling by foot, car, or public transport and an urban business locator for numerous countries around the world.

It is "a way of organizing the world's information geographically”. Google Map provides integrated business search results, draggable maps, earth view, street view and detailed directions for planning a route between source and multiple destinations.

2.4.2 Mumbai Navigator Mumbai Navigator plans travel within the city of Mumbai using BEST buses and local trains, hence providing shortest bus route scheduling. It also gives information relating to bus routes. The advanced version of Mumbai Navigator helps to find a multimodal route also. Mumbai navigator performs only bus scheduling routing (not shortest path routing) with distance constraint and multimodal scheduling. It neither provides any information related to other constrains like traffic and time nor it provide any mechanism of handling alternate paths when any edge is broken or congested 2.4.3 MapmyIndia MapmyIndia is India's leader in premium quality digital maps and consumer navigation services.

With India's best maps, MapmyIndia helps to arrive at destination. It also helps to search online for maps, directions and points of interest. MapmyIndia offers consumer products like GPS navigation System and business solutions along with online search of map and directions. 2.4.3 OpenStreetMap OpenStreetMap creates and offers free geographic data such as street maps to anyone who wants them. OpenStreetMap is a non commercialized web mapping service that provides data in the form of xml, gml, osm, image and pdf free of cost, thus allowing any organization to use them as they want

10 Chapter-3 Implementation Performing route finding techniques on a large graph slows down the processing of any algorithm. To increase the efficiency of these algorithm researchers do manual modeling and preprocessing of graphs [13]. This requires too much of preprocessing time, human effort and manual working. To minimize the this time we have developed a new Web Based GIS Route Finder System that not only models and process the road network automatically but also provide different route finder options like Hierarchical, Facility based, Multimodal, Top-k, Alternate path and Shortest Path Route Finder to be handled under one roof.

We process the graph to model it into the automatically created database upon the loading of graph into memory. Once modeled, it is ready for performing route finder operations. Figure 3.1 shows overall view of the system, with different tools used for mapping of real road network into database format and then showing the output and map on the web browser based on the route finder query of the user.

The main goal of the project is to minimize the number of re-computations for route finding between any source ‟s‟ and destination „t‟ along with finding of alternate route when any edge breaks between them. To achieve this, all the coding of our project is implemented in JSP and Java1.5 with the help of following tools: Net Beans: It is a cross platform Java Integrated Development Environment (IDE) allows applications to be developed from a set of modular software components called modules in Java. It uses JVM and JDK is required for developing web application. In our project we have used Net Beans 6.7.1 to develop the Route Finder application.

PostGIS: It is an open source software program that adds support for geographic objects to “spatially enables” the PostgreSQL open source relational database. The database can then be used to store and query spatial data (points, lines and polygons). Thus allowing it to be used as a backend spatial database for Geographic Information Systems (GIS). In our project we have used PostGIS 1.8.4 as a backend.

Geo Server: It is an open source software server written in Java that allows users to share and edit geospatial data and is the realm of GIS. Geo Server implements the Web Map Service (WMS) to display the spatial information as raster images (maps). In our project we have used Geo Server 1.6.1 to display maps on web pages, where the user can zoom and pan around. All the experiments are performed over windows 2.66 GHz machine with 2 GB of memory. The sample dataset is chosen as Hyderabad road network that consists of 1476 roads, 4272 edges, 3977

11 nodes, 27 railway stations and a total of 41 facilities of 5 facility types (Figure shown in Appendix A).

The following java packages are used in development of the system postgresql-8.4-701.jdbc4 : Package to connect Java with PostgreSQL ( PostGIS loaded) database. colt: Package for making memory matrix a sparse matrix. Figure 3.1: Web Based GIS Route Finder System Figure 3.1 shows overall view of our system, where real road network map is converted into Shape or Geography Markup Language (GML) file that is transformed into SQL file for loading into PostGIS + PostgreSQL database. Once loaded into database it is ready for performing any of the route finder options listed from section 3.1 to 3.5.

Entity Relationship (E-R) diagram of our system is shown in figure 3.2. We can perform any of the route finder options on any of the database selected.

The system uses Dijkstra and A-star(A*) for computing point to point pair (P2P) shortest route and Floyd Warshall for computing all to all pair (A2A) shortest route. Since for computation of path by Floyd Warshall algorithm requires memory matrix creation of size 4000*4000 which is not supported by Java therefore for computation we have converted it into sparse matrix. By doing so, computation time increases drastically. The Sparse Matrix we use is internally represented as a hash map where combination of row and column makes a key and matrix content is the value. So, to find a value of (row, column) = (i, j), we compute key corresponding to i and j and then shows the value that this key maps.

The result is shown in section 4.1.

12 Fig 3.2: E-R diagram of Web Based GIS Route Finder 3.1 Shortest Route Finder Shortest Route Finder tries to sort the problem of finding Better Route between two vertices. Better Route may be defined as a route form vertex „u‟ to vertex „v‟ such that the sum of the cost of its constituent edges is minimized. In other way it is quickest way to travel between two vertices. But, these better routes are dependent on some constraints which make routes better for user, depending on their needs. These constraints may vary from travelling distance to time or to traffic congestion depending upon user‟s need of finding better route.

13 Thus, the problem for shortest route finder can be defined as follows: Given: 1. A road network, G= (V, E) where V is the number of nodes or vertices and E is the number of edges 2. A Source „s‟ and a Destination „t‟ Find: [dist (s, t)] or [traffic congestion (s, t)] or [travel time (s, t)] is minimum, where dist, traffic congestion and travel time are network constraints Prior shortest route finder techniques, requires computation of algorithm each time a query occurs. In our project we have modified the concept and have used database for enhancing the response time of each query. We compute the shortest path between source „s‟ and destination „t‟ from algorithm only when there is no path in database that contains this st path as a sub path or there is no direct path from st exists in database.

Once computed st from algorithm, we check if there is any path in database which is sub path of st, we remove that path and store this path instead. The pseudo code for shortest route finder is shown in Table 3.1 Table 3.1: Pseudo Code for Shortest Route Finder Shotest Route Finder Pseudo Code 1 { 2 Enter Source node and Destination Node 3 Check in Database, if any direct path stored, 4 If yes, Display the path and distance 5 If no, Extract all path from Database and check whether if there is any sub path of same source and destination nodes 6 If yes, Display path and distance 7 If no, Compute Path on the basis of preferred algorithm and preferred constraint 8 { 9 Display path and distance 10 Check from all path in database whether this path is super path of any path 11 If yes, remove that path and insert this super path 12 If no, insert this path into database 13 } 14 } 15 Visualize entry with Open layers in Geoserver 16 Continue for other source and destination node

14 3.2 Alternate Route Finder In real network scenario, traffic congestion is the biggest problem. One of the reasons for congestions is that the road capacity is not optimally used. This leads to the development of Route finder systems which use dynamic information about the current state of the road network. By avoiding congested roads and using alternative ways instead the network capacity is exploited in a more optimal way. Alternate Route Finder helps to find an alternate shortest path when an edge between source „s‟ and destination „t‟ breaks or gets congested with heavy traffic. Suppose, if path uv is an intermediate edge in shortest path st, which gets congested or breaks after some time interval then Alternate Route Finder tries to find the next shortest path in which uv is not an intermediate edge.

Thus the problem for alternate route finder can be defined as follows: Given: 1. A road network, G= (V, E) where V is the number of nodes or vertices and E is the number of edges 2. A Source „s‟, Destination „t‟, Start node „u‟ and End node „v‟ of congested/broken edge uv Find: A path such that [dist(s, t)] is next minimum and does not contain uv as an intermediate edge. The main aim of Alternate Route Finder is to minimize the number of re-computation to find next available alternate path. Pseudo code for alternate route finder is shown in table 3.2. Table 3.2: Pseudo Code for Alternate Route Finder Alternate Route Finder Pseudo Code /* Broken edge denoted by brokennode1 (source node of brokenedge) and brokennode2 (destination node of broken edge) */ 1 { 2 Enter Source node, Destination Node, Brokennode1 and Brokennode2 3 Check in alternatepath database whether exist any path entry for source, destination, brokennode1 and brokennode2 pair 4 If yes, 5 { 6 Display path and distance 7 Apply Shortest Route Finder Algorithm

15 3.3 Facility Based Route Finder In the real world, there are many deviations from the shortest path between the source and destination, and it is important to consider these while planning the route that has to be traversed. An important aspect of real life route planning is much more complex than just finding the shortest route. Some trip may need single facility and some may need multiple facilities to be included in the trip. Facility Based Route Finder tries to find the shortest route via these facilities. Facility type may include hospitals, police stations, railway stations, church etc.

Facility based route finder may find shortest route between source „s‟ and destination „t‟ via any of the facility condition: Via Single facility Via list of facilities when ID is known Via list of facilities when ID is unknown Thus the problem for facility based route finder can be defined as follows: Given: 1. A road network, G= (V, E) where V is the number of nodes or vertices and E is the number of edges 2. A Source „s‟ and a Destination „t‟ 3. A set of instances of a facility type, F = { f1,f2,...fn } Find: A facility instance fi that is nearest, Such that [dist(s, fi )+dist(fi, t)] is minimum Finding shortest route st via single facility requires source „s‟, destination „t‟ and a facility type.

Pseudo code for facility based route finder via single facility is provided in table 3.3.1. Similarly, 8 } 9 If no, 10 { 11 Calculate shortest path and distance between source and destination 12 Display path and distance 13 Add to alternatepath database 14 Apply Shortest Route Finder Algorithm 15 } 16 } 17 Visualize entry with Open layers in Geoserver 18 Continue with other source, destination and broken edge nodes

16 finding shortest route st via list of facility when ID is known or unknown requires source „s‟, destination „t‟ and a list of facility ID separated by comma or a list of facility type names separated by space respectively. Pseudo code for facility based route finder via list of facility when ID is known and unknown is provided in table 3.3.2 and 3.3.3 respectively. Table 3.3.1: Pseudo Code for Facility Based Route Finder via Single Facility Table 3.3.2: Pseudo Code for Facility Based Route Finder via List of Facilities (ID Known) Facility Based Route Finder Pseudo Code /* Via single facility*/ 1 { 2 Enter Source node, Destination Node and Facility name 3 Check in singlefacilitypath database whether exist any path entry for source, destination and facility name pair 4 If yes, 5 Display path and distance 6 If no, 7 { 8 Extract the closest facility id 9 Extract nearest neighbor node of facility id 10 Calculate shortest path and distance between source and destination via nearest neighbor 11 Display path and distance 12 Add to singlefacilitypath database 13 } 14 Visualize entry with Open layers in Geoserver 15 Continue with other source, destination and facility name Facility Based Route Finder Pseudo Code /* Via list of facilities, ID of each facilities are known and ID‟s are entered in comma seperated format (CSV format) */ 1 { 2 Enter source node, Destination node and List of facilities ID (f1,f2,...,fn) 3 Search for path in facilitylistidpath database for above pair of source, destination and list of facilities 4 If path found, 5 Display path and distance 6 If not, 7 { 8 Compute shortest path and distance between source and destination via list of

17 Table 3.3.3: Pseudo Code for Facility Based Route Finder via List of Facilities (ID Unknown) 3.4 Hierarchical Route Finder It is common knowledge that in any road network, the roads are classified into various classes such as highways, expressways and residential streets. In real life scenario, a major portion of all journeys lie on major roads such as highways and expressways, which permit faster travel. facility ID‟s 9 Display path and distance 10 } 11 } 12 Visualize path with Open layers in Geoserver 13 Continue with other source, destination and list of facility ID‟s Facility Based Route Finder Pseudo Code /* Via list of facilities, ID of each facilities are unknown and facility types are entered in space seperated format (SSV format) */ 1 { 2 Enter source node, Destination node and List of facilities names (f1 type, f2 type,..., fn type) 3 Search for path in facilitylistpath database for above pair of source, destination and list of facilities 4 If path found, 5 Display path and distance 6 If not, 7 { 8 Extract the closest facility id for each facility type 9 Extract nearest neighbor node for closest facility id for each facility type // got in above step 10 Calculate shortest path and distance between source and destination via nearest neighbors 11 Display path and distance 12 Add to singlefacilitypath database 13 } 14 } 15 Visualize path with Open layers in Geoserver 16 Continue with other source, destination and list of facility types

18 Hierarchical Route Finder logically partitions the graph into following three Levels of Hierarchies (LOH) Level of Hierarchy 1 (LOH 1) – Only Highways (Fastest Paths) Level of Hierarchy 2 (LOH 2) – Highways (Fastest Paths) and Expressways (Fast Paths) Level of Hierarchy 3 (LOH 3) – All Roads (Combination of all Fastest, Fast and Slowest Paths) Thus, the shortest route computed by hierarchical route finder will be based on time constraint so, even if the distance to travel is large the travel time will be less.

Level of Hierarchy specifies the view of road network. As we increase the hierarchy level, deeper view and specification of road network will be displayed.

Viewing LOH 1 will display the upper layer i.e. only highways of road network (see figure 7) similarly viewing LOH 2 and LOH 3 will display the intermediate layer i.e. highways and expressways of road network (see figure 8) and lower layer i.e. all roads of road network (see figure 9). Fig 3.3: Level of Hierarchies in Road Network When a path between source „s‟ and destination „t‟ is computed in LOH 1, it tries to find the path in highway that is nearer to source and destination. So, if the nearer highway point from „s‟ is „h1‟ and nearer highway point from „t‟ is „h2‟ then the path computed by hierarchical route finder will be sh1h2t where paths from sh1 and h2t will be computed by taking time as a constraint.

Similarly, for LOH 2 also the path computation technique is same. For computation of path in LOH 3 we don‟t need to find any nearer highway or expressway point, the shortest path st will be computed by taking time as a constraint. Pseudo code for Hierarchical Route Finder is shown in table 3.4

19 Table 3.4: Pseudo Code for Hierarchical Route Finder 3.5 Multimodal Route Finder A multimodal route finder lets you plan routes using multiple modes of transportation. The purpose of multimodal route finder is to provide the better route between source and destination, where the route may utilize different modes of transportation. A multimode route between source „s‟ and destination „t‟ is generated using different mode of public transport. Multimodal Route Hierarchical Route Finder Pseudo Code /* Level of Hierarchy 1 (LOH 1)– shows only highway roads (path found will contain maximum highway road) Level of Hierarchy 2 (LOH 2)– shows highway roads and expressway roads (path found will contain maximum highway and expressway roads) Level of Hierarchy 3 (LOH 3)– shows all roads (path found will be on the basis of maximum speed of the road */ 1 { 2 Enter source node and Destination node 3 Select Level of Hierarchy 1, 2 or 3 4 Search for path in hierarchicalpath database for above pair of source, destination and level of hierarchy 5 If path found, 6 Display path and distance 7 If not, 8 { 9 Generate a graph of only highway roads, 10 Extract nearest highway neighbor node for source and destination 11 Search for shortest path in highway graph for nearest highway nodes found in above step 12 Search for path from source to nearest highway node from source with time constraint 13 Search for path from destination to nearest highway node from destination with time constraint 14 Combine all paths 15 Display path and distance 16 Add to hierarchicalpath database 17 } 18 } 19 Visualize path with Open layers in Geoserver 20 Continue with other source, destination and different level of hierarchy

20 Finder helps in finding the route by combining different mode of public transportation. There may be different mode of public transport but in this project we have used Road and Railways. Thus the problem for multimodal route finder can be defined as follows: Given: 4. A road network, G= (V, E) where V is the number of nodes or vertices and E is the number of edges 5. A Source „s‟ and a Destination „t‟ 6. A set of instances of a railway station type, R = { r1,r2,...rn } Find: Railway station instance rst rd that is nearest to source and destination respectively, Such that [travel time(s, rst )+path(rst, rd)+travel time(rd, t)] is minimum, where travel time is a constraint.

Multimodal route finder computes the path by finding the nearest railway stations from source and destination and then finding the shortest route from source and destination to nearest railway stations with speed or time as a constraint. Suppose we want to compute a multimodal route between source „s‟ and destination „t‟, the nearest railway stations from source and destination are found to be R1 and R2 then the route will be sR1R2t (R1 is nearest railway station from source and R2 is nearest railway station from destination) where routes from sR1 and R2t are computed with speed or time as a constraint.

Pseudo code for multimodal route finder is shown in table 4.5.

Table 3.5: Pseudo Code for Multimodal Route Finder Multimodal Route Finder Pseudo Code /* Multimodal route consists of road and rail network */ 1 { 2 Enter source node and Destination node 3 Search for path in multimodalpath database for above pair of source and destination 4 If path found, 5 Display path and distance 6 If not, 7 { 8 Generate a graph of roads and railway network, 9 Extract nearest railway station node for source and destination 10 Compute shortest path in railway network between nearest railway stations found in above step 11 Compute shortest path from source to nearest railway station from source with

21 time constraint 12 Compute shortest path from destination to nearest railway station from destination with time constraint 13 Combine all paths 14 Display multimodal path and distance 15 Add to multimodalpath database 16 Compute shortest path with time constraint between source and destination 17 Display road path and distance 18 } 19 } 20 Visualize path with Open layers in Geoserver 21 Continue with other source, destination and level of hierarchy

22 Chapter-4 Experimentation 4.1 Experiment Results Experiment result section will discuss about following three results: 1.

Effect of Floyd Warshall with normal matrix creation vs. Floyd Warshall with sparse matrix in java on space and time complexity: As discussed earlier, Java does not support memory matrix creation of 4000* 4000 nodes for our dataset, we demonstrate here via graph how much is the capacity of normal memory matrix creation and how time complexity drastically changes when converting it into sparse. Although sparse matrix creation is taking much time, the only advantage is that it allows matrix to be created of any size. The relation between time and space complexity of normal vs. sparse matrix creation is shown in Table 4.2 (A) and Figure 4.1 Table 4.2 (A): Normal matrix complexity vs.

Sparse matrix complexity Sl. No. Matrix Size Time taken by normal matrix Time taken by sparse matrix 1 50*50 ~1 sec ~14 sec 2 1000*1000 ~4 sec ~4 min 10 sec (~250 sec) 3 2500*2500 ~37 sec ~5 min 50 sec (~350 sec) 4 4000*4000 Java Heap Size Error ~7 min 10 sec (~430 sec) Figure 4.1: Normal matrix complexity vs. Sparse matrix complexity

23 Floyd Warshall with sparse matrix yield better results than Dijkstra and A-star when either we have to calculate shortest route between each and every node or when we have first time created path matrix and then we are computing shortest route between any (source, destination) pair or we have to calculate shortest route between each and every node. We have randomly taken 500 source and destination pairs for computing shortest route and then taken the average of their time of computation for comparison. The result is shown in Table 4.2 (B).

Table 4.2 (B): Result of comparing FW, Dijkstra and A-star (A*) Sl.

No. Condition for shortest route finder Average Dijkstra computation time* (in seconds) Average A-star computation time* (in seconds) Average Floyd Warshall computation time* (in seconds) 1 Shortest route query between any (s,t) node pair ~1.8 ~ 1.7 (with less node expansion in graph) 68 min (for first time path and distance matrix creation) + ~1 sec (for finding path in matrix) 2 Shortest route between each and every node pair 4000*4000*1.8 =2,88,00,000 4000*4000*1.7 =2,72,00,000 68*60 + 1*4000*4000 =1,60,04,080 * shows result taken over 500 random source and destination pairs The comparison shows that for finding path between all pairs, Floyd Warshall is working much better than other algorithms.

2. Executing shortest route query using normal computation of algorithms vs. Executing shortest route query using our approach. Finding shortest route in normal approach requires executing algorithm every time a shortest route finder query is encountered while in our approach following steps are performed when a shortest route finder query is encountered a) If shortestpath table in database is empty, compute route from executing algorithm and store source, destination and path into database. b) If shortestpath table in database is not empty, Extract all routes from table, Search whether source node „s‟ and destination node „t‟ both is present in any route.

If so, extract substring between „s‟ and „t which is shortest route between source „s‟ and destination „t‟.

24 If no route contains source and destination node both, compute route by executing desired shortest route finder algorithm. Check in table whether computed route is super path of any route stored. If so, remove that and insert this route else only insert this route. Suppose, we have a route 12345678910 stored in database table as a shortest route between source node „1‟ and destination node „10‟ or source node „10‟ and destination node „1‟ in reverse direction (as all edges are bi-directional), then for all subset of cardinality 2 of set {2,3,4,5,6,7,8,9} where number denotes source or destination nodes, we don‟t need to either compute route from algorithm nor we need computed route to be store in the database table.

Therefore, by storing a route with „n‟ nodes, we can save the space required for storing (n*(n-1)) routes.

The formulae for calculating total time taken for computing shortest route using normal approach and using our approach is shown below. Computation time using normal approach =Computation time for query by executing algorithm Database access time + searching time (if found), Computation time using our approach= Database access time + searching time + execution time for algorithm + storing time (if not found) To prove the correctness of our approach we have taken 2000 random source and destination pairs and then apply our approach on it.

The result is as follows: Initially database is empty hence first path is calculated and stored time taken= ~ 2 seconds Average database access time + searching time = ~ 1.5 second

25 Figure 4.2: Normal approach vs. our approach Figure 4.3: Actual path generated vs. Path stored by our approach Figure 4.2 shows how average time complexity varies in normal approach and in our approach. From graph it is cleared that our approach seems to be better than normal approach as after certain number of routes generated and stored in database, there is no need of computing path from algorithm hence the average time of computation restricts to route accessing and searching from database only thereby making it constant. Similarly, Figure 4.3 shows that for random 2000 queries normal approach would require 2000 route generation whereas our approach requires only 798 routes to be generated and stored.

26 remaining routes could easily be obtained from the stored ones thereby making space complexity less than normal approach. 3. Creation of different modules of route finder options. As discussed earlier, we have developed and migrated modules of route finder options like shortest route finder, alternate route finder, top-k shortest route finder, hierarchical route finder, facility based route finder and multimodal route finder into single unit known as Web Based GIS Route Finder System. The screenshots of system is attached from appendix A to appendix E.