| | |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTDB</key> |
| | | <value>true</value> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTFILE</key> |
| | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | |
| | | |
| | | private String dataOut = null; |
| | | |
| | | private HashMap featuresContext = new HashMap(); |
| | | private HashMap featuresWriterContext = new HashMap(); |
| | | private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>(); |
| | | private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>(); |
| | | |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | | private FeatureTypeBuilder typeBuilder = null; |
| | |
| | | |
| | | if (!txFeaturesContext.containsKey(feature.getFeatureType())) |
| | | { |
| | | txFeaturesContext.put(feature.getFeatureType(), new ArrayList()); |
| | | txFeaturesContext.put(feature.getFeatureType(), new ArrayList<Feature>()); |
| | | } |
| | | ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType()); |
| | | ArrayList<Feature> arrayList = (ArrayList<Feature>) txFeaturesContext.get(feature.getFeatureType()); |
| | | arrayList.add(feature); |
| | | } else |
| | | { |
| | |
| | | FeatureWriter writer; |
| | | if (featuresWriterContext.containsKey(featureType.getTypeName())) |
| | | { |
| | | writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()); |
| | | writer = 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); |
| | | ArrayList<Feature> features = featuresContext.get(featureType); |
| | | Iterator itFeature = features.iterator(); |
| | | while (itFeature.hasNext()) |
| | | { |
| | |
| | | dataOut = outPath.toString(); |
| | | } |
| | | return dataOut; |
| | | } |
| | | |
| | | public void closeFeatureWriter() throws IOException { |
| | | |
| | | for (FeatureWriter featureWriter : this.featuresWriterContext.values()) |
| | | { |
| | | featureWriter.close(); |
| | | } |
| | | |
| | | this.featuresWriterContext.clear(); |
| | | } |
| | | |
| | | public FeatureType createPointFeatureElement(String featureName) throws SchemaException |
| | |
| | | { |
| | | 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; |
| | | Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | if (geom != null) |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | colorTable.getColorCode(linestring.getColorIndex()), |
| | | linestring.getWeight(), |
| | | linestring.getLineStyle() |
| | | }); |
| | | return null; |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | LineElement line = (LineElement) element; |
| | |
| | | line.getLineStyle() |
| | | }); |
| | | return null; |
| | | /* |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | ArcElement arcElement = (ArcElement) element; |
| | | convertDecorator.setConverter(arcElement); |
| | | Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | if (geom != null) |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | colorTable.getColorCode(arcElement.getColorIndex()), |
| | | arcElement.getWeight(), |
| | | arcElement.getLineStyle() |
| | | }); |
| | | return null; |
| | | */ |
| | | /* |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | ArcElement arcElement = (ArcElement) element; |
| | | convertDecorator.setConverter(arcElement); |
| | | Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | if (geom != null) |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | colorTable.getColorCode(arcElement.getColorIndex()), |
| | | arcElement.getWeight(), |
| | | arcElement.getLineStyle() |
| | | }); |
| | | return null; |
| | | */ |
| | | } |
| | | return null; |
| | | } |
| | |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | /* |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "A"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | /* |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | featureTypes.put(typeName, createArcFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | */ |
| | | typeName = getFeatureBaseName() + "A"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createArcFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | */ |
| | | } |
| | | |
| | | return null; |
| | |
| | | |
| | | private String dataOut = null; |
| | | |
| | | private HashMap featuresContext = new HashMap(); |
| | | private HashMap featuresWriterContext = new HashMap(); |
| | | private HashMap<String, ArrayList<Feature> > featuresContext = new HashMap<String, ArrayList<Feature> >(); |
| | | private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>(); |
| | | |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | | private FeatureTypeBuilder typeBuilder = null; |
| | |
| | | FeatureWriter writer; |
| | | if(featuresWriterContext.containsKey(featureType.getTypeName())) |
| | | { |
| | | writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()) ; |
| | | writer = 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()) |
| | | ArrayList<Feature> features = featuresContext.get(featureType); |
| | | for (Feature feature1 : features) |
| | | { |
| | | Feature feature = (Feature) itFeature.next(); |
| | | Feature feature = feature1; |
| | | ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null)); |
| | | } |
| | | //writer.close(); |
| | |
| | | dataOut = outPath.toString(); |
| | | } |
| | | return dataOut; |
| | | } |
| | | |
| | | public void closeFeatureWriter() throws IOException { |
| | | |
| | | for (FeatureWriter featureWriter : this.featuresWriterContext.values()) |
| | | { |
| | | featureWriter.close(); |
| | | } |
| | | |
| | | this.featuresWriterContext.clear(); |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | |
| | | TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())), |
| | | }); |
| | | |
| | | Feature feature = featureType.create(new Object[]{ |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | extent.getMinX(), |
| | | extent.getMinY(), |
| | |
| | | textElement.getWeight(), |
| | | textElement.getLineStyle() |
| | | }); |
| | | return feature; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | exetcuteConvert(jobContext, orgSchema, _dataPath); |
| | | |
| | | //close all open filewriter instance |
| | | jobContext.closeFeatureWrite(); |
| | | jobContext.closeFeatureWriter(); |
| | | } |
| | | } |
| | | |
| | |
| | | scanIndexDgnElement(convertContext); |
| | | |
| | | convertContext.commitTransaction(); |
| | | convertContext.closeFeatureWriter(); |
| | | System.gc(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | |
| | | scanOtherDgnElement(convertContext); |
| | | |
| | | convertContext.commitTransaction(); |
| | | convertContext.closeFeatureWriter(); |
| | | System.gc(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | |
| | | private ElementDispatcher elementDispatcher; |
| | | |
| | | private HashMap featuresContext = new HashMap(); |
| | | private HashMap featuresWriterContext = new HashMap(); |
| | | private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>(); |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | | |
| | | private JobExecutionContext executionContext; |
| | |
| | | FeatureWriter writer = null; |
| | | if(featuresWriterContext.containsKey(featureType.getTypeName())) |
| | | { |
| | | writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()) ; |
| | | writer = 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); |
| | | } |
| | | |
| | |
| | | * Ãö³¬³]³Æ¼g¤J¾¹ |
| | | * @throws IOException IOµo¥Í¿ù»~ |
| | | */ |
| | | public void closeFeatureWrite() throws IOException { |
| | | Iterator iter = this.featuresWriterContext.values().iterator(); |
| | | public void closeFeatureWriter() throws IOException { |
| | | |
| | | while(iter.hasNext()) |
| | | for (FeatureWriter featureWriter : this.featuresWriterContext.values()) |
| | | { |
| | | FeatureWriter writer = (FeatureWriter) iter.next(); |
| | | writer.close(); |
| | | featureWriter.close(); |
| | | } |
| | | |
| | | this.featuresWriterContext = null; |
| | | this.featuresWriterContext.clear(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * fromTM2(TWD97_A, TWD97_ECC, TWD97_ECC2, 0, 121, TWD97_TM2, &dx, &dy); |
| | | * |
| | | * printf("TM2->TWD97nTM2 (%f, %f)nConvert (%.9f, %.9f)nOrigin (%.9f, %.9f)n", tx2, ty2, dx, dy, x2, y2); |
| | | * printf("TM2->TWD97nTM2 (%f, %f)nConvert (%.9f, %.9f)\nOrigin (%.9f, %.9f)\n", tx2, ty2, dx, dy, x2, y2); |
| | | * printf("Acuuracy (%.9f, X:%.9f, Y:%.9f)nn", sqrt((dx-x2)*(dx-x2)+(dy-y2)*(dy-y2)), (dx-x2), (dy-y2)); |
| | | * |
| | | * //////////////////////////////////////////// |
| | |
| | | * |
| | | * dx1 += 250000; // TM2 in Taiwan should add 250000 |
| | | * |
| | | * printf("TWD67->TWD97nTWD67 (%.9f, %.9f, %6.2f) (%.3f, %.3f)n", x1, y1, z1, tx1, ty1); |
| | | * printf("TWD67->TWD97\nTWD67 (%.9f, %.9f, %6.2f) (%.3f, %.3f)n", x1, y1, z1, tx1, ty1); |
| | | * printf("Convert (%.9f, %.9f, %6.2f) (%.3f, %.3f)n", dx, dy, dz, dx1, dy1); |
| | | * printf("Origin (%.9f, %.9f, %6.2f) (%.3f, %.3f)n", x2, y2, z2, tx2, ty2); |
| | | * printf("Acuuracy (%.4f, X:%.4f, Y:%.4f)nn", sqrt((dx1-tx2)*(dx1-tx2)+(dy1-ty2)*(dy1-ty2)), (dx1-tx2), (dy1-ty2)); |
| | |
| | | */ |
| | | public static Coordinate fromTM2ToTWD97(Coordinate pt) |
| | | { |
| | | Coordinate ptTWD97 = toTWD97(fromTM2(TWD67_A, TWD67_ECC, TWD67_ECC2, 0, 121, TWD67_TM2, pt.x - 250000.0, pt.y)); |
| | | Coordinate ptTWD67 = fromTM2(TWD67_A, TWD67_ECC, TWD67_ECC2, 0, 121, TWD67_TM2, pt.x - 250000.0, pt.y); |
| | | ptTWD67.z = 0; |
| | | Coordinate ptTWD97 = toTWD97(ptTWD67); |
| | | Coordinate pt97TM2 = toTM2(TWD97_A, TWD97_ECC, TWD97_ECC2, 0, 121, TWD97_TM2, ptTWD97.x, ptTWD97.y); |
| | | pt97TM2.x += 250000; |
| | | return pt97TM2; |