| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | //~--- JDK imports ------------------------------------------------------------ |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | |
| | | |
| | | import org.apache.log4j.Logger; |
| | | |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryCollection; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | /** |
| | |
| | | { |
| | | private static final Logger logger = Logger.getLogger(ComplexChainElement.class); |
| | | |
| | | protected ArrayList list = new ArrayList(); |
| | | protected ArrayList<Element> list = new ArrayList<Element>(); |
| | | |
| | | public ComplexChainElement(byte[] raw) |
| | | { |
| | |
| | | |
| | | public boolean add(Object o) |
| | | { |
| | | return list.add(o); |
| | | return list.add((Element) o); |
| | | } |
| | | |
| | | public boolean remove(Object o) |
| | |
| | | |
| | | public Object set(int index, Object element) |
| | | { |
| | | return list.set(index, element); |
| | | return list.set(index, (Element) element); |
| | | } |
| | | |
| | | public void add(int index, Object element) |
| | | { |
| | | list.add(index, element); |
| | | list.add(index, (Element) element); |
| | | } |
| | | |
| | | public Object remove(int index) |
| | |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | ArrayList<Geometry> list = new ArrayList<Geometry>(); |
| | | |
| | | if (size() == 1) |
| | | { |
| | | Element element = (Element) get(0); |
| | |
| | | } |
| | | } |
| | | |
| | | CoordinateList pts = new CoordinateList(); |
| | | for (ListIterator it = listIterator(); it.hasNext();) |
| | | { |
| | | Element element = (Element) it.next(); |
| | |
| | | { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) |
| | | { |
| | | list.add(((LineStringElement) element).toGeometry(factory)); |
| | | pts.add(((LineStringElement) element).toGeometry(factory).getCoordinates(), true); |
| | | } |
| | | |
| | | } else if (element instanceof LineElement) |
| | |
| | | |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) |
| | | { |
| | | list.add(((LineElement) element).toGeometry(factory)); |
| | | pts.add(((LineElement) element).toGeometry(factory).getCoordinates(), true); |
| | | } |
| | | /* |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | list.add(((ArcElement) element).toGeometry(factory)); |
| | | */ |
| | | pts.add(((ArcElement) element).toGeometry(factory).getCoordinates(), true); |
| | | } |
| | | } |
| | | |
| | | Geometry[] ga = list.toArray(new Geometry[list.size()]); |
| | | |
| | | return new GeometryCollection(ga, factory); |
| | | return factory.createLineString(pts.toCoordinateArray()); |
| | | } |
| | | |
| | | public double getElementSize() |