From f26cdb4382420cb98e96237914cf21ae351ceecb Mon Sep 17 00:00:00 2001
From: ?? ? <ulysseskao@ximple.com.tw>
Date: Mon, 17 Mar 2008 17:31:01 +0800
Subject: [PATCH] update for EOFM-17

---
 ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java |   55 +++++++++++++------------------------------------------
 1 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java b/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
index 5fee393..4e410fa 100644
--- a/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
+++ b/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
@@ -1,9 +1,6 @@
 package com.ximple.eofms.jobs;
 
-import java.io.File;
-import java.io.IOException;
 import java.math.BigDecimal;
-import java.net.MalformedURLException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.sql.ResultSet;
@@ -17,19 +14,7 @@
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-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.FeatureCollection;
-import org.geotools.feature.FeatureCollections;
-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 org.opengis.geometry.Geometry;
 import org.quartz.JobDetail;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -48,7 +33,6 @@
 import com.ximple.io.dgn7.Element;
 import com.ximple.io.dgn7.ElementType;
 import com.ximple.io.dgn7.IElementHandler;
-import com.ximple.io.dgn7.LineElement;
 import com.ximple.util.PrintfFormat;
 
 /**
@@ -73,6 +57,8 @@
             this.second = second;
         }
     }
+
+    GeometryFactory _geomFactory = new GeometryFactory();
 
     public Log getLogger()
     {
@@ -132,6 +118,7 @@
             {
                 // OracleConnection connection = jobContext.getOracleConnection();
                 // connection.commit();
+                jobContext.commit();
                 System.gc();
             }
         }
@@ -250,7 +237,9 @@
 
             try
             {
-                onBinaryElement(raw);
+                Element element = fetchBinaryElement(raw);
+                jobContext.putFeatureCollection(element);
+
             } catch (Dgn7fileException e)
             {
                 logger.warn("Dgn7Exception", e);
@@ -293,7 +282,8 @@
 
             try
             {
-                onBinaryElement(rawDest);
+                Element element = fetchBinaryElement(rawDest);
+                // Feature feature = convertElementToFeature(element);
             } catch (Dgn7fileException e)
             {
                 logger.warn("Dgn7Exception:" + e.getMessage(), e);
@@ -301,7 +291,7 @@
         }
     }
 
-    private void onBinaryElement(byte[] raws) throws Dgn7fileException
+    private Element fetchBinaryElement(byte[] raws) throws Dgn7fileException
     {
         ByteBuffer buffer = ByteBuffer.wrap(raws);
         buffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -358,36 +348,20 @@
             }
         }
 
-        Feature feature = convertElementToFeature(dgnElement);
+        return dgnElement;
     }
 
     private Feature convertElementToFeature(Element dgnElement)
     {
-        GeometryFactory geomFactory = new GeometryFactory();
-        FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance("Line");
-
-        typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class));
-        typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class));
-        typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class));
-        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("SYMCOLOR", Integer.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("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.setNamespace(new URI(""));
+        /*
         Feature feature = null;
         try
         {
             FeatureType featureType = typeBuilder.getFeatureType();
             feature = featureType.create(new Object[]{
-                    ((LineElement) dgnElement).toGeometry(geomFactory)
+                    ((LineElement) dgnElement).toGeometry(_geomFactory)
             });
 
             FeatureCollection features = FeatureCollections.newCollection();
@@ -412,6 +386,7 @@
         {
             logger.warn(e.getMessage(), e);
         }
+        */
 
 
         return null;
@@ -435,8 +410,4 @@
         return true;
     }
 
-    public FeatureCollection loopupFeatureCollection(String name)
-    {
-        return null;
-    }
 }

--
Gitblit v0.0.0-SNAPSHOT