| | |
| | | { |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | FeatureTypeBuilder typeBuilder = null; |
| | | TWD97GeometryConverterDecorator convertDecordator = new TWD97GeometryConverterDecorator(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | |
| | | public CreateLineStringStrategy() |
| | | { |
| | |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | } |
| | |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | LineStringElement lineStringElement = (LineStringElement) element; |
| | | convertDecordator.setConverter(lineStringElement); |
| | | convertDecorator.setConverter(lineStringElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | lineStringElement.getLevelIndex(), |
| | | colorTable.getColorCode(lineStringElement.getColorIndex()), |
| | | colorTable.getColor(lineStringElement.getColorIndex()).getRGB(), |
| | | lineStringElement.getWeight(), |
| | | lineStringElement.getLineStyle() |
| | | }); |
| | |
| | | } else if (element instanceof ComplexChainElement) |
| | | { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | convertDecordator.setConverter(complexChain); |
| | | convertDecorator.setConverter(complexChain); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | complexChain.getLevelIndex(), |
| | | colorTable.getColorCode(complexChain.getColorIndex()), |
| | | colorTable.getColor(complexChain.getColorIndex()).getRGB(), |
| | | complexChain.getWeight(), |
| | | complexChain.getLineStyle() |
| | | }); |
| | |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | LineElement lineElement = (LineElement) element; |
| | | convertDecordator.setConverter(lineElement); |
| | | convertDecorator.setConverter(lineElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | lineElement.getLevelIndex(), |
| | | colorTable.getColorCode(lineElement.getColorIndex()), |
| | | colorTable.getColor(lineElement.getColorIndex()).getRGB(), |
| | | lineElement.getWeight(), |
| | | lineElement.getLineStyle() |
| | | }); |
| | |
| | | import com.ximple.eofms.jobs.TWD97GeometryConverterDecorator; |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.TWDDatumConverter; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | |
| | | public class CreateLineTextStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | FeatureTypeBuilder typeBuilder = null; |
| | | TWD97GeometryConverterDecorator convertDecordator = new TWD97GeometryConverterDecorator(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | |
| | | public CreateLineTextStrategy() |
| | | { |
| | |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | } |
| | |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | LineStringElement lineStringElement = (LineStringElement) element; |
| | | convertDecordator.setConverter(lineStringElement); |
| | | convertDecorator.setConverter(lineStringElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | lineStringElement.getLevelIndex(), |
| | | colorTable.getColorCode(lineStringElement.getColorIndex()), |
| | | colorTable.getColor(lineStringElement.getColorIndex()).getRGB(), |
| | | lineStringElement.getWeight(), |
| | | lineStringElement.getLineStyle() |
| | | }); |
| | |
| | | vect[1] = TWDDatumConverter.fromTM2ToTWD97(ptEnd); |
| | | |
| | | LineString line = geometryFactory.createLineString(vect); |
| | | // convertDecordator.setConverter(txtElement); |
| | | // Geometry geom = convertDecordator.toGeometry(geometryFactory); |
| | | // convertDecorator.setConverter(txtElement); |
| | | // Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | |
| | | txtElement.getRotationAngle(); |
| | | |
| | |
| | | 0, |
| | | txtElement.getLevelIndex(), |
| | | colorTable.getColorCode(txtElement.getColorIndex()), |
| | | colorTable.getColor(txtElement.getColorIndex()).getRGB(), |
| | | txtElement.getWeight(), |
| | | txtElement.getLineStyle() |
| | | }); |
| | |
| | | } else if (element instanceof ComplexChainElement) |
| | | { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | convertDecordator.setConverter(complexChain); |
| | | convertDecorator.setConverter(complexChain); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | complexChain.getLevelIndex(), |
| | | colorTable.getColorCode(complexChain.getColorIndex()), |
| | | colorTable.getColor(complexChain.getColorIndex()).getRGB(), |
| | | complexChain.getWeight(), |
| | | complexChain.getLineStyle() |
| | | }); |
| | |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | LineElement lineElement = (LineElement) element; |
| | | convertDecordator.setConverter(lineElement); |
| | | convertDecorator.setConverter(lineElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | lineElement.getLevelIndex(), |
| | | colorTable.getColorCode(lineElement.getColorIndex()), |
| | | colorTable.getColor(lineElement.getColorIndex()).getRGB(), |
| | | lineElement.getWeight(), |
| | | lineElement.getLineStyle() |
| | | }); |
| | |
| | | { |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | FeatureTypeBuilder typeBuilder = null; |
| | | TWD97GeometryConverterDecorator convertDecordator = new TWD97GeometryConverterDecorator(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | |
| | | public CreateShapeStrategy() |
| | | { |
| | |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | } |
| | |
| | | if (element instanceof ShapeElement) |
| | | { |
| | | ShapeElement shapeElement = (ShapeElement) element; |
| | | convertDecordator.setConverter(shapeElement); |
| | | convertDecorator.setConverter(shapeElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | shapeElement.getLevelIndex(), |
| | | colorTable.getColorCode(shapeElement.getColorIndex()), |
| | | colorTable.getColor(shapeElement.getColorIndex()).getRGB(), |
| | | shapeElement.getWeight(), |
| | | shapeElement.getLineStyle() |
| | | }); |
| | |
| | | } else if (element instanceof ComplexShapeElement) |
| | | { |
| | | ComplexShapeElement complexShape = (ComplexShapeElement) element; |
| | | convertDecordator.setConverter(complexShape); |
| | | convertDecorator.setConverter(complexShape); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | complexShape.getLevelIndex(), |
| | | colorTable.getColorCode(complexShape.getColorIndex()), |
| | | colorTable.getColor(complexShape.getColorIndex()).getRGB(), |
| | | complexShape.getWeight(), |
| | | complexShape.getLineStyle() |
| | | }); |
| | |
| | | { |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | FeatureTypeBuilder typeBuilder = null; |
| | | TWD97GeometryConverterDecorator convertDecordator = new TWD97GeometryConverterDecorator(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | |
| | | public CreateTextStrategy() |
| | | { |
| | |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", String.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); |
| | |
| | | double angle = txtElement.getRotationAngle(); |
| | | angle += 180.0; |
| | | angle = ((angle > 360.0)? (angle - 360.0) : (angle)); |
| | | convertDecordator.setConverter(txtElement); |
| | | convertDecorator.setConverter(txtElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | txtElement.getLevelIndex(), |
| | | colorTable.getColorCode(txtElement.getColorIndex()), |
| | | colorTable.getColor(txtElement.getColorIndex()).getRGB(), |
| | | txtElement.getWeight(), |
| | | txtElement.getLineStyle(), |
| | | txtElement.getFontIndex(), |
| | |
| | | } else if (element instanceof TextNodeElement) |
| | | { |
| | | TextNodeElement nodeElement = (TextNodeElement) element; |
| | | convertDecordator.setConverter(nodeElement); |
| | | convertDecorator.setConverter(nodeElement); |
| | | String[] texts = nodeElement.getTextArray(); |
| | | StringBuffer sb = new StringBuffer(); |
| | | for (String text : texts) |
| | |
| | | angle += 180.0; |
| | | angle = ((angle > 360.0)? (angle - 360.0) : (angle)); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecordator.toGeometry(geometryFactory), |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | (int) fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (int) fLinkage.getComponentID(), |
| | | 0, |
| | | nodeElement.getLevelIndex(), |
| | | colorTable.getColorCode(nodeElement.getColorIndex()), |
| | | colorTable.getColor(nodeElement.getColorIndex()).getRGB(), |
| | | nodeElement.getWeight(), |
| | | nodeElement.getLineStyle(), |
| | | nodeElement.getFontIndex(), |
| | |
| | | package com.ximple.eofms.jobs; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.MalformedURLException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.apache.commons.transaction.memory.PessimisticMapWrapper; |
| | | import org.apache.commons.transaction.util.CommonsLoggingLogger; |
| | | import org.apache.commons.transaction.util.LoggerFacade; |
| | | import org.geotools.data.FeatureWriter; |
| | | import org.geotools.data.Transaction; |
| | | import org.geotools.data.shapefile.ShapefileDataStore; |
| | | import org.geotools.feature.AttributeTypeFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.SimpleFeature; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | |
| | | public class GeneralDgnConvertJobContext extends AbstractDgnFileJobContext |
| | | { |
| | | private final static String SHPOUTPATH = "shpout"; |
| | | static final Log logger = LogFactory.getLog(IndexDgnConvertJobContext.class); |
| | | static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); |
| | | static final GeometryFactory geometryFactory = new GeometryFactory(); |
| | | static final String SHPOUTPATH = "shpout"; |
| | | |
| | | private String dataOut = null; |
| | | |
| | | private HashMap featuresContext = new HashMap(); |
| | | private HashMap featuresWriterContext = new HashMap(); |
| | | |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | | private FeatureTypeBuilder typeBuilder = null; |
| | | private TreeMap<String, FeatureType> featureTypes = new TreeMap<String, FeatureType>(); |
| | | |
| | | private TWD97GeometryConverterDecorator convertDecorator = null; |
| | | private String featureBaseName = null; |
| | | |
| | | public GeneralDgnConvertJobContext(String dataPath) |
| | | { |
| | | super(dataPath); |
| | | txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); |
| | | convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | } |
| | | |
| | | public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException |
| | | { |
| | | FeatureType ft = lookupFeatureType(element); |
| | | if (ft == null) |
| | | { |
| | | Feature feature = createFeature(ft, element); |
| | | if (feature == null) |
| | | { |
| | | logger.info("cannot craete feature." + element.toString() + "'" + |
| | | ((TextElement) element).getText() + "'"); |
| | | return; |
| | | } |
| | | |
| | | if (!txFeaturesContext.containsKey(feature.getFeatureType())) |
| | | { |
| | | txFeaturesContext.put(feature.getFeatureType(), new ArrayList()); |
| | | } |
| | | ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType()); |
| | | arrayList.add(feature); |
| | | } else |
| | | { |
| | | logger.info("Unknown Element :" + element.getType() + ", lv=" + element.getLevelIndex()); |
| | | } |
| | | } |
| | | |
| | | public void startTransaction() |
| | |
| | | |
| | | public void commitTransaction() |
| | | { |
| | | if (!txFeaturesContext.isEmpty()) |
| | | { |
| | | logger.debug("Transaction size = " + txFeaturesContext.size()); |
| | | //txFeaturesContext.commitTransaction(); |
| | | } else |
| | | { |
| | | logger.debug("Transaction is empty."); |
| | | } |
| | | |
| | | if (!featuresContext.isEmpty()) |
| | | { |
| | | updateDataStore(); |
| | | } |
| | | } |
| | | |
| | | public void rollbackTransaction() |
| | | { |
| | | //txFeaturesContext.rollbackTransaction(); |
| | | if (!featuresContext.isEmpty()) |
| | | { |
| | | updateDataStore(); |
| | | } |
| | | } |
| | | |
| | | private void updateDataStore() |
| | | { |
| | | Iterator it = featuresContext.keySet().iterator(); |
| | | |
| | | try |
| | | { |
| | | while (it.hasNext()) |
| | | { |
| | | FeatureType featureType = (FeatureType) it.next(); |
| | | File sfile = new File(getDataOutPath() + "\\" + featureType.getTypeName()); |
| | | logger.debug("Begin Save shapefile:" + sfile.toURI()); |
| | | |
| | | FeatureWriter writer; |
| | | if (featuresWriterContext.containsKey(featureType.getTypeName())) |
| | | { |
| | | writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()); |
| | | } else |
| | | { |
| | | ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL()); |
| | | shapefileDataStore.createSchema(featureType); |
| | | writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); |
| | | if (this.featuresWriterContext == null) |
| | | { |
| | | this.featuresWriterContext = new HashMap(); |
| | | } |
| | | featuresWriterContext.put(featureType.getTypeName(), writer); |
| | | } |
| | | |
| | | ArrayList features = (ArrayList) featuresContext.get(featureType); |
| | | Iterator itFeature = features.iterator(); |
| | | while (itFeature.hasNext()) |
| | | { |
| | | Feature feature = (Feature) itFeature.next(); |
| | | ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null)); |
| | | } |
| | | //writer.close(); |
| | | logger.debug("End Save shapefile:" + sfile.toURI()); |
| | | } |
| | | featuresContext.clear(); |
| | | } catch (MalformedURLException e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | public String getDataOutPath() |
| | |
| | | } |
| | | return dataOut; |
| | | } |
| | | |
| | | public FeatureType createPointFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (typeBuilder == null) |
| | | { |
| | | 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("JUST", Integer.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); |
| | | typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class)); |
| | | } |
| | | return typeBuilder.getFeatureType(); |
| | | } |
| | | |
| | | public FeatureType createLineFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (typeBuilder == null) |
| | | { |
| | | 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)); |
| | | } |
| | | return typeBuilder.getFeatureType(); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException |
| | | { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | if (element instanceof TextElement) |
| | | { |
| | | TextElement textElement = (TextElement) element; |
| | | convertDecorator.setConverter(textElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | colorTable.getColorCode(textElement.getColorIndex()), |
| | | textElement.getFontIndex(), |
| | | textElement.getJustification(), |
| | | textElement.getTextHeight(), |
| | | textElement.getTextWidth(), |
| | | textElement.getRotationAngle(), |
| | | textElement.getText() |
| | | }); |
| | | return feature; |
| | | } else if (element instanceof LineStringElement) |
| | | { |
| | | LineStringElement linestring = (LineStringElement) element; |
| | | convertDecorator.setConverter(linestring); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | colorTable.getColorCode(linestring.getColorIndex()), |
| | | linestring.getWeight(), |
| | | linestring.getLineStyle() |
| | | }); |
| | | return feature; |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | LineElement line = (LineElement) element; |
| | | convertDecorator.setConverter(line); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | colorTable.getColorCode(line.getColorIndex()), |
| | | line.getWeight(), |
| | | line.getLineStyle() |
| | | }); |
| | | return feature; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String getFeatureBaseName() |
| | | { |
| | | if (featureBaseName == null) |
| | | { |
| | | String dgnname = getFilename().toLowerCase(); |
| | | int i = dgnname.lastIndexOf("."); |
| | | if (i != -1) |
| | | { |
| | | dgnname = dgnname.substring(0, i); |
| | | } |
| | | featureBaseName = dgnname; |
| | | } |
| | | return featureBaseName; |
| | | } |
| | | private FeatureType lookupFeatureType(Element element) throws SchemaException, IllegalAttributeException |
| | | { |
| | | String typeName; |
| | | if (element instanceof TextElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "P"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createPointFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof LineStringElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "L"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "L"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Iterator; |
| | | import java.net.MalformedURLException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.AttributeTypeFactory; |
| | | import org.geotools.feature.FeatureTypeFactory; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SimpleFeature; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.apache.commons.transaction.memory.PessimisticMapWrapper; |
| | | import org.apache.commons.transaction.util.CommonsLoggingLogger; |
| | | import org.apache.commons.transaction.util.LoggerFacade; |
| | | import org.geotools.data.FeatureWriter; |
| | | import org.geotools.data.Transaction; |
| | | import org.geotools.data.shapefile.ShapefileDataStore; |
| | | import org.apache.commons.transaction.memory.PessimisticMapWrapper; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.AttributeTypeFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.SimpleFeature; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Envelope; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | |
| | | import com.ximple.io.dgn7.Dgn7fileReader; |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.TPCLIDConverter; |
| | | import com.ximple.eofms.util.TWDDatumConverter; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.ShapeElement; |
| | | import com.ximple.io.dgn7.ComplexShapeElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; |
| | | import com.ximple.eofms.util.TPCLIDConverter; |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.StringUtils; |
| | | |
| | | public class IndexDgnConvertJobContext extends AbstractDgnFileJobContext |
| | | { |
| | | static Log logger = LogFactory.getLog(IndexDgnConvertJobContext.class); |
| | | static GeometryFactory geometryFactory = new GeometryFactory(); |
| | | private final static String SHPOUTPATH = "shpout"; |
| | | static final Log logger = LogFactory.getLog(IndexDgnConvertJobContext.class); |
| | | static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); |
| | | static final GeometryFactory geometryFactory = new GeometryFactory(); |
| | | static final String SHPOUTPATH = "shpout"; |
| | | |
| | | private String dataOut = null; |
| | | |
| | |
| | | public IndexDgnConvertJobContext(String dataPath) |
| | | { |
| | | super(dataPath); |
| | | txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); |
| | | } |
| | | |
| | | public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException |
| | |
| | | File sfile = new File(getDataOutPath() + "\\" + featureType.getTypeName()); |
| | | logger.debug("Begin Save shapefile:" + sfile.toURI()); |
| | | |
| | | FeatureWriter writer = null; |
| | | FeatureWriter writer; |
| | | if(featuresWriterContext.containsKey(featureType.getTypeName())) |
| | | { |
| | | writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()) ; |
| | |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | |
| | | } |
| | | |
| | | public String getDataOutPath() |
| | |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | if (element instanceof TextElement) |
| | | { |
| | | TextElement textElm = (TextElement) element; |
| | | String tpclid = textElm.getText(); |
| | | TextElement textElement = (TextElement) element; |
| | | String tpclid = textElement.getText(); |
| | | |
| | | Envelope extent = TPCLIDConverter.convertTpclIdToEnvelope(tpclid); |
| | | Geometry geom = geometryFactory.createLinearRing(new Coordinate[] |
| | | { |
| | | new Coordinate(extent.getMinX(), extent.getMinY()), |
| | | new Coordinate(extent.getMaxX(), extent.getMinY()), |
| | | new Coordinate(extent.getMaxX(), extent.getMaxY()), |
| | | new Coordinate(extent.getMinX(), extent.getMaxY()), |
| | | new Coordinate(extent.getMinX(), extent.getMinY()), |
| | | TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())), |
| | | TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMaxX(), extent.getMinY())), |
| | | TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMaxX(), extent.getMaxY())), |
| | | TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMaxY())), |
| | | TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())), |
| | | }); |
| | | |
| | | TextElement textElement = (TextElement) element; |
| | | Feature feature = featureType.create(new Object[]{ |
| | | geom, |
| | | extent.getMinX(), |
| | |
| | | package com.ximple.eofms.jobs; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.File; |
| | | import java.io.FilenameFilter; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FilenameFilter; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | |
| | | import java.sql.Statement; |
| | | import java.sql.Types; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Iterator; |
| | | |
| | | import org.apache.commons.collections.OrderedMap; |
| | | import org.apache.commons.collections.OrderedMapIterator; |
| | | import org.apache.commons.collections.map.LinkedMap; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.Envelope; |
| | | |
| | | import oracle.jdbc.OracleConnection; |
| | | import oracle.jdbc.OracleResultSet; |
| | |
| | | |
| | | import com.ximple.eofms.util.BinConverter; |
| | | import com.ximple.eofms.util.ByteArrayCompressor; |
| | | import com.ximple.eofms.util.TPCLIDConverter; |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import com.ximple.io.dgn7.ComplexElement; |
| | | import com.ximple.io.dgn7.Dgn7fileException; |
| | | import com.ximple.io.dgn7.Dgn7fileReader; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.ElementType; |
| | | import com.ximple.io.dgn7.IElementHandler; |
| | | import com.ximple.io.dgn7.Dgn7fileReader; |
| | | import com.ximple.io.dgn7.Lock; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.ComplexShapeElement; |
| | | import com.ximple.io.dgn7.TextNodeElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.util.PrintfFormat; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public class OracleConvertDgn2ShpJob extends AbstractOracleDatabaseJob |
| | | { |
| | | static Log logger = LogFactory.getLog(OracleConvertDgn2ShpJob.class); |
| | | final static Log logger = LogFactory.getLog(OracleConvertDgn2ShpJob.class); |
| | | |
| | | private static final int FETCHSIZE = 30; |
| | | private static final int BATCHSIZE = 25; |
| | |
| | | { |
| | | lastComplex = null; |
| | | |
| | | processElement(element, convertContext); |
| | | processIndexElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | processElement(element, convertContext); |
| | | processIndexElement(element, convertContext); |
| | | lastComplex = element; |
| | | } |
| | | } |
| | |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processElement(Element element, IndexDgnConvertJobContext convertContext) throws IllegalAttributeException, SchemaException |
| | | private void processIndexElement(Element element, IndexDgnConvertJobContext convertContext) throws IllegalAttributeException, SchemaException |
| | | { |
| | | if (element instanceof TextElement) |
| | | { |
| | |
| | | * °õ¦æÂà´«¨ä¥L³]p¹ÏÀɪº¤u§@ |
| | | * @param context |
| | | */ |
| | | private void convertOtherDesignFile(JobExecutionContext context) |
| | | private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | File otherDir = new File(getDataPath(), "other"); |
| | | if (!otherDir.exists()) |
| | |
| | | for (File dgnFile : dgnFiles) |
| | | { |
| | | GeneralDgnConvertJobContext convertContext = new GeneralDgnConvertJobContext(getDataPath()); |
| | | convertContext.setExecutionContext(context); |
| | | try |
| | | { |
| | | convertContext.setExecutionContext(context); |
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.pathSeparator); |
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]); |
| | | |
| | | FileInputStream fs = new FileInputStream(dgnFile); |
| | | FileChannel fc = fs.getChannel(); |
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock()); |
| | | convertContext.setReader(reader); |
| | | |
| | | scanOtherDgnElement(convertContext); |
| | | |
| | | convertContext.commitTransaction(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (SchemaException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void scanOtherDgnElement(GeneralDgnConvertJobContext convertContext) throws Dgn7fileException, IOException |
| | | public void scanOtherDgnElement(GeneralDgnConvertJobContext convertContext) |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException |
| | | { |
| | | Dgn7fileReader reader = convertContext.getReader(); |
| | | int count = 0; |
| | |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | // @todo add process in here |
| | | lastComplex = null; |
| | | } |
| | | lastComplex = null; |
| | | |
| | | // @todo add process in here |
| | | processOtherElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | // @todo add process in here |
| | | processOtherElement(element, convertContext); |
| | | lastComplex = element; |
| | | } |
| | | } |
| | | |
| | | if (element.getElementType().isComplexElement()) |
| | | { |
| | | if (element instanceof ComplexChainElement) |
| | | { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | int size = complexChain.size(); |
| | | for (Object aComplexChain : complexChain) |
| | | { |
| | | Element subElement = (Element) aComplexChain; |
| | | subElement.getType(); |
| | | } |
| | | } |
| | | |
| | | if (element instanceof ComplexShapeElement) |
| | | { |
| | | ComplexShapeElement complexShape = (ComplexShapeElement) element; |
| | | } |
| | | |
| | | if (element instanceof TextNodeElement) |
| | | { |
| | | TextNodeElement textNode = (TextNodeElement) element; |
| | | int size = textNode.size(); |
| | | for (int i = 0; i < size; i++) |
| | | { |
| | | Element subElement = (Element) textNode.get(i); |
| | | subElement.getElementType(); |
| | | } |
| | | } |
| | | |
| | | } else |
| | | { |
| | | boolean hasLinkage = false; |
| | | if (element instanceof TextElement) |
| | | { |
| | | TextElement textElm = (TextElement) element; |
| | | List<UserAttributeData> usrData = textElm.getUserAttributeData(); |
| | | Iterator<UserAttributeData> it = usrData.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | UserAttributeData attr = it.next(); |
| | | if (attr instanceof FrammeAttributeData) |
| | | { |
| | | hasLinkage = true; |
| | | System.out.println("------------------------------------------"); |
| | | System.out.println("FSC=" + ((FrammeAttributeData) attr).getFsc() + ":" + |
| | | ((FrammeAttributeData) attr).getUfid()); |
| | | } |
| | | } |
| | | |
| | | if (hasLinkage) |
| | | { |
| | | System.out.println("Text.Font=" + textElm.getFontIndex()); |
| | | System.out.println("Text.Just=" + textElm.getJustification()); |
| | | System.out.println("usrData.len=" + usrData.size()); |
| | | System.out.println("text=" + textElm.getText()); |
| | | System.out.println("Origin=" + textElm.getOrigin()); |
| | | System.out.println("UserOrigin=" + textElm.getUserOrigin()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | count++; |
| | | } |
| | | |
| | | logger.info("ElementRecord Count=" + count); |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processOtherElement(Element element, GeneralDgnConvertJobContext convertContext) throws IllegalAttributeException, SchemaException |
| | | { |
| | | if (element instanceof TextElement) |
| | | { |
| | | convertContext.putFeatureCollection(element); |
| | | } |
| | | } |
| | | } |