?? ?
2011-11-01 9789467fb349a9e0da5bffe3681293469141c2d2
Symbol with Polygon
2 files modified
48 ■■■■■ changed files
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java 45 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java 3 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java
@@ -1,7 +1,11 @@
package com.ximple.eofms.filter;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.CoordinateArrays;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.ximple.eofms.util.*;
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
@@ -18,6 +22,7 @@
import org.opengis.feature.simple.SimpleFeatureType;
import javax.swing.event.EventListenerList;
import java.awt.geom.AffineTransform;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
@@ -87,6 +92,46 @@
            } else {
                gobj = txtElement.toGeometry(geometryFactory);
            }
            if (gobj instanceof Point) {
                Coordinate p = gobj.getCoordinate();
                double width = txtElement.getTextWidth();
                double height = txtElement.getTextHeight();
                AffineTransform at = new AffineTransform();
                at.translate(width, height);
                at.setToRotation(angle, p.x, p.y);
                at.scale(1, 1);
                Envelope envelope = new Envelope(p);
                envelope.expandBy(width / 2, height / 2);
                double[] srcPt = new double[8];
                double[] dstPt = new double[8];
                srcPt[0] = envelope.getMinX();
                srcPt[1] = envelope.getMinY();
                srcPt[2] = envelope.getMinX();
                srcPt[3] = envelope.getMaxY();
                srcPt[4] = envelope.getMaxX();
                srcPt[5] = envelope.getMaxY();
                srcPt[6] = envelope.getMaxX();
                srcPt[7] = envelope.getMinY();
                at.transform(srcPt, 0, dstPt, 0, 4);
                Coordinate[] coords = new Coordinate[4];
                for (int i = 0; i < 4; i++) {
                    coords[i] = new Coordinate(dstPt[i*2], dstPt[i*2+1]);
                }
                int srid = gobj.getSRID();
                gobj = geometryFactory.createPolygon(geometryFactory.createLinearRing(coords), null);
                if (gobj.getSRID() != srid) {
                    gobj.setSRID(srid);
                }
            } else {
                gobj = null;
            }
            if (gobj != null)
                feature = SimpleFeatureBuilder.build(featureType, new Object[]{
                    gobj,
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java
@@ -422,7 +422,8 @@
        // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Point.class, notAllowNull));
        attrBuilder = new AttributeTypeBuilder();
        attrDescs.add(attrBuilder.buildDescriptor(
                "geom", createGeometryType(attrBuilder, "PointType", Point.class, notAllowNull, lookupCRS(defaultSRID))));
                // "geom", createGeometryType(attrBuilder, "PointType", Point.class, notAllowNull, lookupCRS(defaultSRID))));
            "geom", createGeometryType(attrBuilder, "PolygonType", Polygon.class, notAllowNull, lookupCRS(defaultSRID))));
        // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull));
        attrBuilder = new AttributeTypeBuilder();
        attrDescs.add(attrBuilder.buildDescriptor(