Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: mil84 <milan.sillik@so...>  20110520 16:32:43

Hi, i would like to do app "shortest path finder", so I read something about Graph, and on the beginning I was pleased because it looked very easy :) So I tried very simple example like this: GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); LineStringGraphGenerator lineStringGen = new LineStringGraphGenerator(); Point a = geometryFactory.createPoint(new Coordinate(0, 0)); Point b = geometryFactory.createPoint(new Coordinate(1, 0)); Point c = geometryFactory.createPoint(new Coordinate(1, 1)); Point d = geometryFactory.createPoint(new Coordinate(0, 1)); LineString abcd = geometryFactory.createLineString(new Coordinate[] { new Coordinate(a.getX(), a.getY()), new Coordinate(b.getX(), b.getY()), new Coordinate(c.getX(), c.getY()), new Coordinate(d.getX(), d.getY()) }); LineString ac = geometryFactory.createLineString(new Coordinate[] { new Coordinate(a.getX(), a.getY()), new Coordinate(c.getX(), c.getY()) }); lineStringGen.add(abcd); lineStringGen.add(ac); Graph g = lineStringGen.getGraph(); as u can see, I tried to create just very simple graph with 4 points A,B,C,D and lines between them like this: http://osgeoorg.1803224.n2.nabble.com/file/n6386745/graph.jpg But when i build graph, and use method getNodes(), i have only three nodes (why? i build graph with 4) also edges are different. So of course, when I use DijkstraShortestPathFinder, it also gives me different result. What did I wrong?  View this message in context: http://osgeoorg.1803224.n2.nabble.com/problemwithbuildinggraphtp6386745p6386745.html Sent from the geotoolsgt2users mailing list archive at Nabble.com. 
From: Michael Bedward <michael.bedward@gm...>  20110521 09:37:39

Hello, I'm not very familiar with the graph module, but I think your example will work if done like this: GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null); Coordinate a = new Coordinate(0, 0); Coordinate b = new Coordinate(1, 0); Coordinate c = new Coordinate(1, 1); Coordinate d = new Coordinate(0, 1); LineString ab = gf.createLineString(new Coordinate[]{a, b}); LineString bc = gf.createLineString(new Coordinate[]{b, c}); LineString cd = gf.createLineString(new Coordinate[]{c, d}); LineString ac = gf.createLineString(new Coordinate[]{a, c}); LineStringGraphGenerator gen = new LineStringGraphGenerator(); gen.add(ab); gen.add(bc); gen.add(cd); gen.add(ac); Graph graph = gen.getGraph(); I know that there are other list members who use the graph module regularly so perhaps one of them can correct me if I'm wrong or give you more hints. Michael On 21 May 2011 02:32, mil84 <milan.sillik@...> wrote: > Hi, i would like to do app "shortest path finder", so I read something about > Graph, and on the beginning I was pleased because it looked very easy :) So > I tried very simple example like this: > > > GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); > LineStringGraphGenerator lineStringGen = new LineStringGraphGenerator(); > > Point a = geometryFactory.createPoint(new Coordinate(0, 0)); > Point b = geometryFactory.createPoint(new Coordinate(1, 0)); > Point c = geometryFactory.createPoint(new Coordinate(1, 1)); > Point d = geometryFactory.createPoint(new Coordinate(0, 1)); > > LineString abcd = geometryFactory.createLineString(new Coordinate[] { > new Coordinate(a.getX(), a.getY()), new Coordinate(b.getX(), b.getY()), > new Coordinate(c.getX(), c.getY()), new Coordinate(d.getX(), d.getY()) }); > > LineString ac = geometryFactory.createLineString(new Coordinate[] { > new Coordinate(a.getX(), a.getY()), new Coordinate(c.getX(), c.getY()) }); > > lineStringGen.add(abcd); > lineStringGen.add(ac); > Graph g = lineStringGen.getGraph(); > > > as u can see, I tried to create just very simple graph with 4 points A,B,C,D > and lines between them like this: > > http://osgeoorg.1803224.n2.nabble.com/file/n6386745/graph.jpg > > But when i build graph, and use method getNodes(), i have only three nodes > (why? i build graph with 4) also edges are different. So of course, when I > use DijkstraShortestPathFinder, it also gives me different result. > > What did I wrong? > >  > View this message in context: http://osgeoorg.1803224.n2.nabble.com/problemwithbuildinggraphtp6386745p6386745.html > Sent from the geotoolsgt2users mailing list archive at Nabble.com. > >  > What Every C/C++ and Fortran developer Should Know! > Read this article and learn how Intel has extended the reach of its > nextgeneration tools to help Windows* and Linux* C/C++ and Fortran > developers boost performance applications  including clusters. > http://p.sf.net/sfu/inteldev2devmay > _______________________________________________ > Geotoolsgt2users mailing list > Geotoolsgt2users@... > https://lists.sourceforge.net/lists/listinfo/geotoolsgt2users > 
From: PaulCrease <paul.e.crease@gm...>  20110523 13:32:26

Hi, That is interesting, i think using your code example would mean that only the start node and end node of line abcd would overlap with the start point of line ac, therefore giving three nodes when the graph is built, but I am not 100% on that. If I am right then the example below should also work and return 4 nodes : GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); LineStringGraphGenerator lineStringGen = new LineStringGraphGenerator(); Point a = geometryFactory.createPoint(new Coordinate(0, 0)); Point b = geometryFactory.createPoint(new Coordinate(1, 0)); Point c = geometryFactory.createPoint(new Coordinate(1, 1)); Point d = geometryFactory.createPoint(new Coordinate(0, 1)); LineString abc = geometryFactory.createLineString(new Coordinate[] { new Coordinate(a.getX(), a.getY()), new Coordinate(b.getX(), b.getY()), new Coordinate(c.getX(), c.getY()) }); LineString adc = geometryFactory.createLineString(new Coordinate[] { new Coordinate(a.getX(), a.getY()), new Coordinate(d.getX(), d.getY()), new Coordinate(c.getX(), c.getY()) }); LineString ac = geometryFactory.createLineString(new Coordinate[] { new Coordinate(a.getX(), a.getY()), new Coordinate(c.getX(), c.getY()) }); lineStringGen.add(abc); lineStringGen.add(adc); lineStringGen.add(ac); Graph g = lineStringGen.getGraph(); Additionally, from personal experience when you start applying the Graph library to real network datasets the fun really begins.... :) Kind Regards, Paul.  View this message in context: http://osgeoorg.1803224.n2.nabble.com/problemwithbuildinggraphtp6386745p6394466.html Sent from the geotoolsgt2users mailing list archive at Nabble.com. 
Sign up for the SourceForge newsletter:
No, thanks