I have a program that is calculating the shortest path between 2 points,
using the A Star algorithm.
The route is retrieved in gps coordinates. I am trying to figure out a way
to get the names of the streets that make up the route.
I know it is possible to get the street names with the getAttribute method
of an SimpleFeature object. I reached the point where i can get the name
for each multilinestring existing in the shapefile.
private static List polys2lines(SimpleFeatureCollection networkFC)
{
SimpleFeatureIterator it = networkFC.features();
GeometryFactory fact = new GeometryFactory();
List<LineString> al = new LinkedList<LineString>();
while ( it.hasNext() )
{
SimpleFeature feature = it.next();
MultiLineString mp = (MultiLineString) feature.getAttribute(0);
String streetName = (String) feature.getAttribute("name");
int n = mp.getNumGeometries();
for ( int i = 0 ; i < n ; i++ )
{
Geometry g = mp.getGeometryN(i);
Coordinate[] coords = g.getCoordinates();
LineString ls = fact.createLineString(coords);
al.add(ls);
e.add(new Data(streetName, ls));// add to list a new
object(name, linestring)
}
}
it.close();
return al;
}
However, because the intersections are not noded i have to run a procedure
that would help with that
lines = polys2lines(networkFC);
GeometryFactory geomFactory = new GeometryFactory();
Geometry grandMls = geomFactory.buildGeometry(lines);
Point mlsPt = geomFactory.createPoint(grandMls.getCoordinate());
Geometry nodedLines = grandMls.union(mlsPt);
lines.clear();
for (int k = 0, n = nodedLines.getNumGeometries(); k < n; k++)
{
Geometry g = nodedLines.getGeometryN(k);
if (g instanceof LineString)
{
lines.add((LineString)g);
}
}
But on this point i loose all the possibilities to pass the name to the new
LineStrings created after noding each intersection.
Do you happen to know another way to do this?
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users