20 package org.matsim.core.network.algorithms.intersectionSimplifier;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.apache.logging.log4j.LogManager;
26 import org.apache.logging.log4j.Logger;
27 import org.locationtech.jts.geom.Coordinate;
28 import org.locationtech.jts.geom.Geometry;
29 import org.locationtech.jts.geom.GeometryFactory;
30 import org.locationtech.jts.geom.Polygon;
49 GeometryFactory gf =
new GeometryFactory();
52 List<Coordinate> list =
new ArrayList<Coordinate>();
53 String[] sa = value.split(
",");
55 String[] sa2 = s.substring(1, s.length()-1).split(
";");
56 double x = Double.parseDouble(sa2[0]);
57 double y = Double.parseDouble(sa2[1]);
58 list.add(
new Coordinate(x, y));
61 Coordinate[] ca =
new Coordinate[list.size()];
65 ca[0] = list.getFirst();
66 g = gf.createPoint(ca[0]);
67 }
else if(ca.length == 2){
70 g = gf.createLineString(ca);
72 for(
int i = 0; i < list.size(); i++){
75 g = gf.createPolygon(gf.createLinearRing(ca), null);
83 if(!(o instanceof Geometry)){
84 log.error(
"Could not convert the geometry: it is not of type Geometry. Returning empty string.");
89 Coordinate[] ca = ((Geometry)o).getCoordinates();
90 StringBuilder s =
new StringBuilder();
91 for(
int i = 0; i < ca.length-1; i++){
99 s.append(ca[ca.length - 1].x);
101 s.append(ca[ca.length - 1].y);
String convertToString(Object o)
Geometry convert(String value)