forked from geodmms/xdgnjobs

?? ?
2008-05-13 383a22332d7df1481e090add1e25406a5a358fd9
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;