Hi Sushil,
From the path you can get to the individual edges. Each edge contains a
"data" object, which is the original linestring.
eg.
Path p = ...
for (Iterator itr = p.getEdges().iterator(); itr.hasNext();) {
Edge e = (Edge)itr.next();
LineString line = (LineString)e.getObject();
}
As for displaying, you could display the path as the collection of
seperate linestrings, but most of the time I have found it useful to
join the linestrings into a single contigous one. There is some utility
code that can do this in
org.geotools.graph.util.GeometryUtil#joinLineStrings.
After you have the single geometry, not sure what the best way to
display it is. I have found that writing the paths to a seperate
shapefile and styling it appropriatly works nicley.
Any more questions just let me know.
-Justin
[EMAIL PROTECTED] wrote:
hi Justin
thanks for ur prompt reply..
below m including th code that i m using...
URL ur1
=MapViewer.class.getClassLoader().getResource("geotool_routing/road_nw.shp");
final DataStore store1 = new ShapefileDataStore(ur1);
FeatureType ft1 = store1.getSchema("road_nw");
final FeatureSource features =
store1.getFeatureSource("road_nw");
LineStringGraphGenerator lgb = new LineStringGraphGenerator();
FeatureResults fsShape = features.getFeatures();
FeatureCollection fc = fsShape.collection();
FeatureIterator feat = fc.features();
//System.out.println("feats===="+feat);
Envelope envelope = fc.getBounds();
while (feat.hasNext())
{
Feature ft = feat.next();
System.out.println("inside====");
if (envelope.contains(ft.getBounds()))
{
//System.out.println("Road ID:"+
ft.getAttribute("Id").toString().trim() + "\tAtribute:"
+ft.getAttribute(0));
lgb.add(ft.getAttribute(0));
}
System.out.println("outside====");
}
Graph g = lgb.getGraph();
Node src1 = lgb.getNode(new Coordinate(3.20469314429218,
712.8185448235371));
Node dest1 = lgb.getNode(new Coordinate(-9.732497499755635,
308.15158580176615));
DijkstraIterator.EdgeWeighter weighter = new
DijkstraIterator.EdgeWeighter()
{
public double getWeight(Edge e)
{System.out.println("soni soni");
//LineSegment line = (LineSegment)e.getObject();
LineString line = (LineString)e.getObject();
System.out.println("length==="+line.getLength());
return(line.getLength());
}
};
DijkstraShortestPathFinder dsp = new DijkstraShortestPathFinder(g, src1,
weighter);
System.out.println("Calculating Paths....");
dsp.calculate();
Path p = dsp.getPath(dest1);
here i m getting the path as
path==[1, 0, 4, 3]
i want it to display this path dynamically on GUI with diffrent colour on
original shape file..
Thanks and Regards
Sushil Kumar Soni
Tata Consultancy Services Limited
Mailto: [EMAIL PROTECTED]
Website: http://www.tcs.com
Notice: The information contained in this e-mail message and/or attachments to
it may contain confidential or privileged information. If you are not the
intended recipient, any dissemination, use, review, distribution, printing or
copying of the information contained in this e-mail message and/or attachments
to it are strictly prohibited. If you have received this communication in
error, please notify us by reply e-mail or telephone and immediately and
permanently delete the message and any attachments. Thank you
--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users