From 94ae08701bbd7585a0b7e5a92d1975965a503c03 Mon Sep 17 00:00:00 2001 From: Dennis Kao <ulysseskao@gmail.com> Date: Wed, 15 Jan 2014 11:28:52 +0800 Subject: [PATCH] Merge branch 'origin/2.1.x' --- xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java | 49 +++++++++++++++++-------------------------------- 1 files changed, 17 insertions(+), 32 deletions(-) diff --git a/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java b/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java index c43458e..6fd7d89 100644 --- a/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java +++ b/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java @@ -2,41 +2,34 @@ import org.apache.log4j.Logger; +import com.vividsolutions.jts.geom.Coordinate; 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 * * @author Ulysses * @version 0.1 - * @since 2006/5/18 �U�� 03:08:43 + * @since 2006/5/18 �U�� 03:08:43 */ -public class ShapeElement extends LineStringElement implements GeometryConverter -{ +public class ShapeElement extends LineStringElement implements GeometryConverter { private static final Logger logger = Logger.getLogger(ShapeElement.class); - public ShapeElement(byte[] raw) - { + ShapeElement(byte[] raw) { super(raw); } - public Coordinate[] getVertices() - { + public Coordinate[] getVertices() { Coordinate[] result = super.getVertices(); - if ((result != null) && (result.length > 2)) - { + if ((result != null) && (result.length > 2)) { boolean isClosed = result[0].equals2D(result[result.length - 1]); - if (!isClosed) - { + if (!isClosed) { double distance = result[0].distance(result[result.length - 1]); - if (distance < 0.00210) - { + if (distance < 0.00210) { result[result.length - 1] = new Coordinate(result[0]); - } else - { + } 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]); @@ -47,40 +40,32 @@ return result; } - public Geometry toGeometry(GeometryFactory factory) - { - try - { + public Geometry toGeometry(GeometryFactory factory) { + try { LinearRing ring = factory.createLinearRing(this.getVertices()); return factory.createPolygon(ring, null); - } catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { logger.warn(e.getMessage(), e); return null; } } - public static class ElementHandler extends Element.ElementHandler - { + public static class ElementHandler extends Element.ElementHandler { private static ElementHandler instance = null; - public ElementHandler() - { + public ElementHandler() { super(ElementType.SHAPE); } - public static IElementHandler getInstance() - { - if (instance == null) - { + public static IElementHandler getInstance() { + if (instance == null) { instance = new ElementHandler(); } return instance; } - protected Element createElement(byte[] raw) - { + protected Element createElement(byte[] raw) { return new ShapeElement(raw); } } -- Gitblit v0.0.0-SNAPSHOT