forked from geodmms/xdgnjobs

?? ?
2008-09-01 741f15ae46171a6df532f7e3727b0fc55acd7d39
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java
@@ -5,6 +5,7 @@
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.Coordinate;
/**
 * ShapeElement
@@ -22,6 +23,30 @@
        super(raw);
    }
    public Coordinate[] getVertices()
    {
        Coordinate[] result = super.getVertices();
        if ((result != null) && (result.length > 2))
        {
            boolean isClosed = result[0].equals2D(result[result.length - 1]);
            if (!isClosed)
            {
                double distance = result[0].distance(result[result.length - 1]);
                if (distance < 0.00210)
                {
                    result[result.length - 1] = new Coordinate(result[0]);
                } else
                {
                    logger.info("Shape is not closed. distance=" + distance);
                    logger.debug("result[0]=" + result[0].toString());
                    logger.debug("result[length - 1]=" + result[result.length - 1]);
                }
            }
        }
        return result;
    }
    public Geometry toGeometry(GeometryFactory factory)
    {
        try