From: Sicky <Chr...@ro...> - 2009-06-16 14:45:20
|
Hi! As you might see I'm a new user and hope everything goes well with my registration/posting here. I've been digging myself into the GeoTools framework for the past weeks but now can't get any more help on my subject on this list or with google. Here's what I have done so far: 1) put some shapes (railroad network, road network and rivers) with osm data (downloaded from geofabrik) into a postgis database 2) displayed the data with geotools 3) build a graph using the LineStringGraphGenerator and just the railroad network data 4) select two points on the map which are on the graph 5) use Dijkstra to find the shortest way between these points. The problem is point 3) I saw that the graph generated is not well connected and checked this with the GraphPartitioner which had approx. 167 partitions while the dataset (railroad network) hast just 531 entries. At that point I informed myself here and got to know that I have to make a point/node whenever 2 lines crosses and make 4 lines from them (or 3 in a special case) Then I saw 2 possible solutions for this here: 1) Use a PolygonGraphGenerator to get the intersection. 2) Split the linestrings in a seperate method and still build the graph with the LineStringGraphGenerator (code taken from here: http://n2.nabble.com/Splitting-LineStrings-at-their-intersection-td1941502.html http://n2.nabble.com/Splitting-LineStrings-at-their-intersection-td1941502.html ) I tried both and run into the following problems: 1) Graph seems to be way to small, resulting graph is: V=[14, 19, 5, 7, 8, 12, 2, 4, 13, 0, 23, 16, 22, 1, 10, 26, 24, 17, 20] E=[3 (2,1), 21 (20,13), 6 (5,1), 9 (8,1), 15 (14,1), 18 (17,1), 25 (24,1), 11 (10,1)] whenever I want to route I get: Shortest path: null 2) I see 2 problems here, first that it doesn't allways find a path, like in this picture/case: http://sicky.i-networx.de/temp/no_shortest_path.png http://sicky.i-networx.de/temp/no_shortest_path.png 2nd problem is that the path looks very strange: http://sicky.i-networx.de/temp/strange_behavior.png http://sicky.i-networx.de/temp/strange_behavior.png The discussion in the topic I mentioned above unde 2) ended apruptly so I don't have a real solution. So, to take this to and end my questions: 1. What's wrong with the code and/or 2. is there an easy way to route with osm data when you use geotools. Here's all you need to understand my problems: Code for the implementation with the splitting of lines: http://sicky.i-networx.de/temp/TestGUI.java http://sicky.i-networx.de/temp/TestGUI.java Code for the polygon stuff: http://sicky.i-networx.de/temp/TestGUI2.java http://sicky.i-networx.de/temp/TestGUI2.java additional needed classes: http://sicky.i-networx.de/temp/DijkstraShortestPath.java http://sicky.i-networx.de/temp/DijkstraShortestPath.java http://sicky.i-networx.de/temp/SelectionTool.java http://sicky.i-networx.de/temp/SelectionTool.java postgis database dump: http://sicky.i-networx.de/temp/imotris_os.backup I hope that was all and my problems are understandable. If there's something missing or if there are any questions, just drop me a line. Thanks in advance for your help :-) -- View this message in context: http://n2.nabble.com/Building-a-connected-graph-with-OSM-data---Splitting-LineStrings-at-their-intersections-tp3086758p3086758.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |