| | |
| | | |
| | | 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; |
| | | } |