static void zerlegen()
{
Iterator<Geometry> it = lines.iterator();
Geometry nodedLineStrings = (LineString) it.next();
while (it.hasNext())
{
nodedLineStrings = nodedLineStrings.union((LineString) it.next());
}
// System.out.println(nodedLineStrings);
// Ergebnis ist GeometryCollection, wird jetzt zerlegt
GeometryCollection col = (GeometryCollection) nodedLineStrings;
for (int i = 0; i < col.getNumGeometries(); i++)
{
Geometry g = col.getGeometryN(i);
// System.out.println(g);
// Achtung: Zerlegung erfolgt nur an den Schnittpunkten
// für Knickpunkte müsste der LineString weiter untersucht werden
LineString ls = (LineString) col.getGeometryN(i);
ls.getNumPoints();
if (ls.getNumPoints()>2)
{
ls.getCoordinateSequence();
String line = reader.readLine();
for (line = reader.readLine(); line != null; line = reader.readLine())
{
if (line.trim().length() > 0)
{
// skip blank lines
}
}
String tokens[] = line.split("\\,");
double x = Double.parseDouble(tokens[0]);
double y = Double.parseDouble(tokens[1]);
String name = tokens[2].trim();
int number = Integer.parseInt(tokens[3].trim());
Line line1 = GeometryFactory.createLineString(new Coordinate(x,y);
System.out.println(ls.getCoordinateSequence());
}
}
}