| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.MalformedURLException; |
| | | import java.nio.charset.Charset; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.nio.charset.Charset; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.Envelope; |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.EllipseElement; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.ShapeElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.EllipseElement; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.TextNodeElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | |
| | | public class GeneralDgnConvertJobContext extends AbstractDgnFileJobContext |
| | | { |
| | |
| | | private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>(); |
| | | |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | | private FeatureTypeBuilder typeBuilder = null; |
| | | private TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | private TreeMap<String, FeatureType> featureTypes = new TreeMap<String, FeatureType>(); |
| | | |
| | | private TWD97GeometryConverterDecorator convertDecorator = null; |
| | |
| | | shapefileDataStore.createSchema(featureType); |
| | | writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), |
| | | Transaction.AUTO_COMMIT); |
| | | } else { |
| | | } else |
| | | { |
| | | ShapefileDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(), |
| | | null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8")); |
| | | writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), |
| | |
| | | return dataOut; |
| | | } |
| | | |
| | | public void closeFeatureWriter() throws IOException { |
| | | public void closeFeatureWriter() throws IOException |
| | | { |
| | | |
| | | for (FeatureWriter featureWriter : this.featuresWriterContext.values()) |
| | | { |
| | |
| | | |
| | | public FeatureType createPointFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (typeBuilder == null) |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", Integer.class)); |
| | |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class)); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | } |
| | | return typeBuilder.getFeatureType(); |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | } |
| | | |
| | | public FeatureType createLineFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (typeBuilder == null) |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | } |
| | | return typeBuilder.getFeatureType(); |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | } |
| | | |
| | | public FeatureType createArcFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (typeBuilder == null) |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | } |
| | | return typeBuilder.getFeatureType(); |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | } |
| | | |
| | | public FeatureType createEllipseFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (typeBuilder == null) |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | } |
| | | return typeBuilder.getFeatureType(); |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException |
| | |
| | | featureTypes.put(typeName, createPointFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof ShapeElement) |
| | | } else if (element instanceof TextNodeElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "P"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createPointFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof LineStringElement) |
| | | { |
| | | if (element instanceof ShapeElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "R"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof LineStringElement) |
| | | } else |
| | | { |
| | | typeName = getFeatureBaseName() + "L"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "L"; |
| | |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof ComplexChainElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "L"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "A"; |