From 2fae905a591201e3d4ee3d463d1d94a504171017 Mon Sep 17 00:00:00 2001 From: ?? ? <ulysseskao@ximple.com.tw> Date: Mon, 17 Mar 2008 19:31:27 +0800 Subject: [PATCH] update for EOFM-17 --- ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/CreateLineStringStrategy.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/CreateLineStringStrategy.java b/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/CreateLineStringStrategy.java index d573c43..5cb5372 100644 --- a/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/CreateLineStringStrategy.java +++ b/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/CreateLineStringStrategy.java @@ -1,14 +1,43 @@ package com.ximple.eofms.jobs; +import java.util.List; + import org.geotools.feature.AttributeTypeFactory; +import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; +import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; import org.opengis.geometry.Geometry; +import com.vividsolutions.jts.geom.GeometryFactory; + +import com.ximple.io.dgn7.Element; +import com.ximple.io.dgn7.FrammeAttributeData; +import com.ximple.io.dgn7.LineStringElement; +import com.ximple.io.dgn7.UserAttributeData; + public class CreateLineStringStrategy implements CreateFeatureTypeStrategy { + GeometryFactory geometryFactory = new GeometryFactory(); FeatureTypeBuilder typeBuilder = null; + + protected FrammeAttributeData getFeatureLinkage(Element element) + { + if (!element.hasUserAttributeData()) + return null; + + List<UserAttributeData> usrDatas = element.getUserAttributeData(); + for (UserAttributeData anUsrData : usrDatas) + { + if (anUsrData instanceof FrammeAttributeData) + { + FrammeAttributeData featureLinkage = (FrammeAttributeData) anUsrData; + return featureLinkage; + } + } + return null; + } public FeatureType createFeatureElement(String featureName) throws SchemaException { @@ -27,4 +56,27 @@ } return typeBuilder.getFeatureType(); } + + public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException + { + FrammeAttributeData fLinkage = getFeatureLinkage(element); + if (fLinkage == null) return null; + if (element instanceof LineStringElement) + { + LineStringElement lineStringElement = (LineStringElement) element; + Feature feature = featureType.create(new Object[]{ + geometryFactory.createLineString(lineStringElement.getVertices()), + (int) fLinkage.getFsc(), + (long) fLinkage.getUfid(), + (int) fLinkage.getComponentID(), + 0, + lineStringElement.getLevelIndex(), + lineStringElement.getColorIndex(), + lineStringElement.getWeight(), + lineStringElement.getLineStyle(), + }); + return feature; + } + return null; + } } -- Gitblit v0.0.0-SNAPSHOT