Hi Jase,

Could you send the stack trace of the exception. Thanks.

Justin

Jase wrote:
Hi Justin,

Upon closer inspection on my database, I found that the roads have been noded on the intersections. MOst of the roads I had a look shares a common end point.

I proceeded on with using some of the algorithms that you suggested in this mailing list. What I'm getting is a null pointer. I'm a bit baffled as to what might have gone wrong. I initially though that the roads might not have been noded so I tried with two points on the same road and got the same results.

Attached are the codes that I used. I'm guessing I did something wrong at the "src" and "dest"

Thanks.

Jase

            DataStore pgDatastore = DataStoreFinder.getDataStore(params);
            FeatureSource fsBC = pgDatastore.getFeatureSource("mustmrr");
System.out.println("Road to be added: " + fsBC.getCount(Query.ALL));
            System.out.println("Reading PostGIS datastore...");
LineStringGraphGenerator lgb = new LineStringGraphGenerator();
            //FeatureSource fs = (FeatureSource)layers.get("mustmrr");
            FeatureResults fr = fsBC.getFeatures();
            FeatureCollection fc = fr.collection();
            FeatureIterator feat = fc.features();
Envelope envelope = fc.getBounds();
            System.out.println("Building graph network...");
            while (feat.hasNext())
            {
                Feature ft = feat.next();
if (envelope.contains(ft.getBounds()))
                {
System.out.println("Road Name:"+ ft.getAttribute("name").toString().trim() + "\tAtribute:" +ft.getAttribute("wkb_geometry"));
                    lgb.add(ft.getAttribute("wkb_geometry"));
} } Graph g = lgb.getGraph(); System.out.println(g); XYNode src = null; src = new BasicXYNode();
            src.setCoordinate(new Coordinate (101.603802, 3.071856));
XYNode dest = new BasicXYNode();
            dest.setCoordinate(new Coordinate(101.71339200,3.15235700));
DijkstraIterator.EdgeWeighter weighter = new DijkstraIterator.EdgeWeighter()
            {
                public double getWeight(Edge e)
                {
                    LineSegment line = (LineSegment)e.getObject();
                    return(line.getLength());
} }; DijkstraShortestPathFinder dsp = new DijkstraShortestPathFinder(g, src, weighter);
            System.out.println("Calculating Paths....");
dsp.calculate(); Path p = dsp.getPath(dest);
            System.out.println(p);


--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to