| | |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.MultiLineString; |
| | | import com.vividsolutions.jts.geom.LineString; |
| | | |
| | | /** |
| | | * ComplexChainElement |
| | |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | if (size() == 1) |
| | | { |
| | | Element element = (Element) get(0); |
| | | ArrayList<LineString> lineStrings = new ArrayList<LineString>(); |
| | | |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) |
| | | { |
| | | return ((LineStringElement) element).toGeometry(factory); |
| | | } |
| | | |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) |
| | | { |
| | | return ((LineElement) element).toGeometry(factory); |
| | | } |
| | | |
| | | } else |
| | | { |
| | | if (element instanceof GeometryConverter) |
| | | { |
| | | return ((GeometryConverter) element).toGeometry(factory); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | CoordinateList pts = new CoordinateList(); |
| | | for (ListIterator it = listIterator(); it.hasNext();) |
| | | { |
| | | Element element = (Element) it.next(); |
| | |
| | | { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) |
| | | { |
| | | pts.add(((LineStringElement) element).toGeometry(factory).getCoordinates(), true); |
| | | lineStrings.add((LineString) ((LineStringElement) element).toGeometry(factory)); |
| | | } |
| | | |
| | | } else if (element instanceof LineElement) |
| | |
| | | |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) |
| | | { |
| | | pts.add(((LineElement) element).toGeometry(factory).getCoordinates(), true); |
| | | lineStrings.add((LineString) ((LineElement) element).toGeometry(factory)); |
| | | } |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | pts.add(((ArcElement) element).toGeometry(factory).getCoordinates(), true); |
| | | lineStrings.add((LineString) ((ArcElement) element).toGeometry(factory)); |
| | | } |
| | | } |
| | | |
| | | return factory.createLineString(pts.toCoordinateArray()); |
| | | LineString[] lines = lineStrings.toArray(new LineString[lineStrings.size()]); |
| | | if ((lines == null) || (lines.length == 0)) |
| | | return null; |
| | | return factory.createMultiLineString(lines); |
| | | } |
| | | |
| | | public double getElementSize() |