From: Satyanarayana M. P. <sat...@re...> - 2005-11-09 07:50:04
|
=0AHi jason,=0AConsidering your Queries I think you have just begun the W= ork.=0Ahere is Somehting that i can Help you out with.=0ADo U want to Load = the Graph Network at all times and Create a route for =0APoints A and B ? = =0A=0AThis is the most Optimum way of Doing that cause ur Data Change would= be minimum and Loading the graph in memory( provided its not so huge ) wou= ld remove the overhead of Data reading and Graph Creating Everythime for ev= ery request for a Route.=0A=0AGo through the Pathgenerators class which All= ow you to find a Path based on Constraints.Constrains can be Distance or Cu= stomized on Various Parameters based on an interface. I think u will get be= tter idea of this when you look at the API's provided.=0AThis Shoudl Solve = your problem.Implementation of Routing Algorithms is also there in geo-tool= s like Dijkstra's et all ..making your job more simpler.=0A=0A=0AAm Providi= ng a Sample Code for ur Understanding :=0AGraph g =3D lsg.getGraph(); // g= e tthe Graph from the Data. or from ur global variable.=0A=0AMEdgeWeighterI= mpl mwi =3D new MEdgeWeighterImpl(); //Cost based Implementaion that u need= to refer to from the API depending on your needs ..Someitmes if Trafic dat= a present then even that is to be Consiered ..et all.. =0A=0Amwi.setEdgeC= ostMap(hmEdgeCost);=0ADijkstraShortestPathFinder dspf =3D new DijkstraShort= estPathFinder(g, srcNode, mwi);=0Adspf.calculate();=0APath p =3D dspf.getPa= th(destNode);=0Aif (p !=3D null) {=0A return p.getEdges();=0A = // actual Rooute Edges .=0A } else =0A {= =0A return null;=0A //No Route found Case .=0A }=0A= =0A=0A=0A=0AGood Luck Dude ..happy Routing .=0A=0ABye.=0A=0A=0A=0A=0A=0A=0A= =0A=0A=0A=0A=0AOn Tue, 08 Nov 2005 Jase wrote :=0A>My current research invo= lves using open source libraries to create an online=0A>vehicle routing sys= tem for taxis or any vehicles as a matter of fact. I have=0A>done some rese= arch and identified Geotools & Geoserver as the best libraries=0A>for build= ing such a system. After going through the mailing list, it seems=0A>that t= he question I am going to ask is quite a common one afterall but there=0A>i= s a lack of solution.=0A>=0A>I have a PostGIS database of roads in LineStri= ngs. After following the=0A>tutorials on graphing, I have managed to create= the graph network using the=0A>LineStringGraphGenerator. What I did was to= load the entire PostGIS database=0A>into the linestringgraphgenerator the = and the output that I have obtained=0A>using getGraph() is as follows:-=0A>= =0A>V =3D [14042, 3162, 2002, 12968 =85 ]=0A>E =3D [20301 (6097, 20300) =85= ]=0A>Is it right to build the entire line network first before traversing = even=0A>though I do not know the points I would like to use?=0A>=0A>I under= stand I should traverse the graph but I am a bit stuck as to how I=0A>shoul= d proceed. Say, if I would like to route from Point A to Point B, how=0A>wo= uld I do that? As a matter of fact, I would like to locate the closest=0A>v= ehicle in a particular area and find the quickest route to that point. I=0A= >see that there are many classes that are in the org.geotools.graph package= =0A>but I'm unsure on how to proceed.=0A>=0A>I appreciate if anyone can off= er an insight to this.=0A>=0A>Thanks=0A>=0A>Jason=0A |