forked from geodmms/xdgnjobs

?? ?
2010-04-08 fe682356cf9d8afbc1bf93963a502592d8e9c50c
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java
@@ -21,12 +21,12 @@
import org.geotools.data.FeatureWriter;
import org.geotools.data.Transaction;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.indexed.IndexType;
import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.feature.SimpleFeature;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.xml.sax.SAXException;
import com.vividsolutions.jts.geom.GeometryFactory;
@@ -51,7 +51,7 @@
    private String dataOut = null;
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, ArrayList<SimpleFeature>> featuresContext = new HashMap<String, ArrayList<SimpleFeature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
@@ -109,8 +109,7 @@
            return;
        }
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element, isTransformed(), isEPSG3826());
        SimpleFeature feature = elementDispatcher.execute(element, isTransformed(), isEPSG3826());
        if (feature == null) {
            FrammeAttributeData linkage =
                AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
@@ -171,7 +170,7 @@
        try {
            while (it.hasNext()) {
                FeatureType featureType = (FeatureType) it.next();
                SimpleFeatureType featureType = (SimpleFeatureType) it.next();
                File sfile = new File(getDataOutPath() + File.separator + featureType.getTypeName());
                logger.debug("Begin Save shapefile:" + sfile.toURI());
@@ -186,24 +185,24 @@
                    */
                    if (!sfile.exists()) {
                        ShapefileDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(),
                                                                                              null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8"));
                                null, true, true, IndexType.QIX, Charset.forName("UTF-8"));
                        shapefileDataStore.createSchema(featureType);
                        writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(),
                                                                     Transaction.AUTO_COMMIT);
                    } else {
                        ShapefileDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(),
                                                                                              null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8"));
                                null, true, true, IndexType.QIX, Charset.forName("UTF-8"));
                        writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                                                           Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                ArrayList<SimpleFeature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext()) {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                    SimpleFeature feature = (SimpleFeature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes());
                }
                //writer.close();
                logger.debug("End Save shapefile:" + sfile.toURI());