From 383a22332d7df1481e090add1e25406a5a358fd9 Mon Sep 17 00:00:00 2001
From: ?? ? <ulysseskao@ximple.com.tw>
Date: Tue, 13 May 2008 18:27:28 +0800
Subject: [PATCH] update for EOFM-83

---
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/GeneralDgnConvertJobContext.java |   85 ++++++++++++++++++++++++++++++------------
 1 files changed, 61 insertions(+), 24 deletions(-)

diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/GeneralDgnConvertJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/GeneralDgnConvertJobContext.java
index fef0b39..6062b40 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/GeneralDgnConvertJobContext.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/GeneralDgnConvertJobContext.java
@@ -36,6 +36,8 @@
 import com.ximple.io.dgn7.ShapeElement;
 import com.ximple.io.dgn7.TextElement;
 import com.ximple.io.dgn7.UserAttributeData;
+import com.ximple.io.dgn7.ArcElement;
+import com.ximple.io.dgn7.EllipseElement;
 
 public class GeneralDgnConvertJobContext extends AbstractDgnFileJobContext
 {
@@ -82,6 +84,11 @@
                     logger.info("cannot craete feature." + element.toString() + "'" +
                             ((LineStringElement) element).getVerticeSize() + "'" +
                             ((LineStringElement) element).getStartPoint());
+                else if (element instanceof ArcElement)
+                    logger.info("cannot craete feature." + element.toString() + "'" +
+                            ((ArcElement) element).getOrigin().toString() + "'" +
+                            ((ArcElement) element).getRotationAngle());
+
                 return;
             }
 
@@ -244,6 +251,19 @@
         return typeBuilder.getFeatureType();
     }
 
+    public FeatureType createEllipseFeatureElement(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();
@@ -313,21 +333,32 @@
                         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;
+        } else if (element instanceof EllipseElement)
+        {
+            EllipseElement arcElement = (EllipseElement) 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;
     }
@@ -382,16 +413,22 @@
                 featureTypes.put(typeName, createLineFeatureElement(typeName));
             }
             return featureTypes.get(typeName);
-            /*
-            } else if (element instanceof ArcElement)
+        } else if (element instanceof ArcElement)
+        {
+            typeName = getFeatureBaseName() + "A";
+            if (!featureTypes.containsKey(typeName))
             {
-                typeName = getFeatureBaseName() + "A";
-                if (!featureTypes.containsKey(typeName))
-                {
-                    featureTypes.put(typeName, createArcFeatureElement(typeName));
-                }
-                return featureTypes.get(typeName);
-            */
+                featureTypes.put(typeName, createArcFeatureElement(typeName));
+            }
+            return featureTypes.get(typeName);
+        } else if (element instanceof EllipseElement)
+        {
+            typeName = getFeatureBaseName() + "R";
+            if (!featureTypes.containsKey(typeName))
+            {
+                featureTypes.put(typeName, createEllipseFeatureElement(typeName));
+            }
+            return featureTypes.get(typeName);
         }
 
         return null;

--
Gitblit v0.0.0-SNAPSHOT