| | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.ShapeElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | |
| | |
| | | public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException |
| | | { |
| | | FeatureType ft = lookupFeatureType(element); |
| | | if (ft == null) |
| | | if (ft != null) |
| | | { |
| | | Feature feature = createFeature(ft, element); |
| | | if (feature == null) |
| | | { |
| | | logger.info("cannot craete feature." + element.toString() + "'" + |
| | | ((TextElement) element).getText() + "'"); |
| | | if (element instanceof TextElement) |
| | | logger.info("cannot craete feature." + element.toString() + "'" + |
| | | ((TextElement) element).getText() + "'"); |
| | | else if (element instanceof ShapeElement) |
| | | logger.info("cannot craete feature." + element.toString() + "'" + |
| | | ((ShapeElement) element).getVerticeSize() + "'" + |
| | | ((ShapeElement) element).getStartPoint()); |
| | | else if (element instanceof LineStringElement) |
| | | logger.info("cannot craete feature." + element.toString() + "'" + |
| | | ((LineStringElement) element).getVerticeSize() + "'" + |
| | | ((LineStringElement) element).getStartPoint()); |
| | | return; |
| | | } |
| | | |
| | |
| | | while (it.hasNext()) |
| | | { |
| | | FeatureType featureType = (FeatureType) it.next(); |
| | | File sfile = new File(getDataOutPath() + "\\" + featureType.getTypeName()); |
| | | File sfile = new File(getDataOutPath() + File.separator + featureType.getTypeName()); |
| | | logger.debug("Begin Save shapefile:" + sfile.toURI()); |
| | | |
| | | FeatureWriter writer; |
| | |
| | | { |
| | | outPath.mkdir(); |
| | | } |
| | | dataOut = getDataPath() + SHPOUTPATH; |
| | | dataOut = outPath.toString(); |
| | | } |
| | | return dataOut; |
| | | } |
| | |
| | | return typeBuilder.getFeatureType(); |
| | | } |
| | | |
| | | public FeatureType createArcFeatureElement(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(); |
| | |
| | | { |
| | | TextElement textElement = (TextElement) element; |
| | | convertDecorator.setConverter(textElement); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | colorTable.getColorCode(textElement.getColorIndex()), |
| | | textElement.getFontIndex(), |
| | | textElement.getJustification(), |
| | | textElement.getTextHeight(), |
| | | textElement.getTextWidth(), |
| | | textElement.getRotationAngle(), |
| | | textElement.getText() |
| | | }); |
| | | return feature; |
| | | Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | if (geom != null) |
| | | { |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | colorTable.getColorCode(textElement.getColorIndex()), |
| | | textElement.getFontIndex(), |
| | | textElement.getJustification(), |
| | | textElement.getTextHeight(), |
| | | textElement.getTextWidth(), |
| | | textElement.getRotationAngle(), |
| | | textElement.getText() |
| | | }); |
| | | } else |
| | | { |
| | | logger.info("geometry is null." + element.toString()); |
| | | } |
| | | return null; |
| | | } else if (element instanceof ShapeElement) |
| | | { |
| | | ShapeElement shapeElement = (ShapeElement) element; |
| | | convertDecorator.setConverter(shapeElement); |
| | | Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | if (geom != null) |
| | | { |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | colorTable.getColorCode(shapeElement.getColorIndex()), |
| | | shapeElement.getWeight(), |
| | | shapeElement.getLineStyle() |
| | | }); |
| | | } else |
| | | { |
| | | logger.info("geometry is null." + element.toString()); |
| | | } |
| | | return null; |
| | | } else if (element instanceof LineStringElement) |
| | | { |
| | | LineStringElement linestring = (LineStringElement) element; |
| | |
| | | { |
| | | LineElement line = (LineElement) element; |
| | | convertDecorator.setConverter(line); |
| | | Feature feature = featureType.create(new Object[]{ |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | colorTable.getColorCode(line.getColorIndex()), |
| | | line.getWeight(), |
| | | line.getLineStyle() |
| | | }); |
| | | return feature; |
| | | Geometry geom = convertDecorator.toGeometry(geometryFactory); |
| | | if (geom != null) |
| | | return featureType.create(new Object[]{ |
| | | geom, |
| | | colorTable.getColorCode(line.getColorIndex()), |
| | | line.getWeight(), |
| | | 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; |
| | | */ |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | return featureBaseName; |
| | | } |
| | | |
| | | private FeatureType lookupFeatureType(Element element) throws SchemaException, IllegalAttributeException |
| | | { |
| | | String typeName; |
| | |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createPointFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof ShapeElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "R"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | } else if (element instanceof LineStringElement) |
| | |
| | | featureTypes.put(typeName, createLineFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | /* |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | typeName = getFeatureBaseName() + "A"; |
| | | if (!featureTypes.containsKey(typeName)) |
| | | { |
| | | featureTypes.put(typeName, createArcFeatureElement(typeName)); |
| | | } |
| | | return featureTypes.get(typeName); |
| | | */ |
| | | } |
| | | |
| | | return null; |