From fe4bda7d456c106e1061afaa29d452e5553e9d96 Mon Sep 17 00:00:00 2001 From: ?? ? <ulysseskao@ximple.com.tw> Date: Wed, 14 May 2008 19:40:53 +0800 Subject: [PATCH] update for EOFM-83 --- xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-) diff --git a/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java b/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java index ed020a2..57a4d89 100644 --- a/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java +++ b/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java @@ -1,12 +1,14 @@ package com.ximple.io.dgn7; +import java.nio.ByteOrder; + import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; public class EllipseElement extends Element implements GeometryConverter { - public EllipseElement(short[] raw) + public EllipseElement(byte[] raw) { super(raw); } @@ -31,10 +33,12 @@ public double getPrimary() { - short[] primary = new short[4]; - - System.arraycopy(raw, 18, primary, 0, 4); - + rawBuffer.position(18 * 2); + ByteOrder bo = rawBuffer.order(); + rawBuffer.order(ByteOrder.BIG_ENDIAN); + byte[] primary = new byte[8]; + rawBuffer.get(primary); + rawBuffer.order(bo); return Utility.convertDGNToIEEEDouble(primary) / 1000.0; } @@ -48,10 +52,12 @@ public double getSecondary() { - short[] secondary = new short[4]; - - System.arraycopy(raw, 22, secondary, 0, 4); - + rawBuffer.position(22 * 2); + ByteOrder bo = rawBuffer.order(); + rawBuffer.order(ByteOrder.BIG_ENDIAN); + byte[] secondary = new byte[8]; + rawBuffer.get(secondary); + rawBuffer.order(bo); return Utility.convertDGNToIEEEDouble(secondary) / 1000.0; } @@ -66,7 +72,6 @@ public double getRotationAngle() { int rotation = (raw[26] << 16 & 0xffff0000); - rotation |= raw[27] & 0x0000ffff; return Utility.converIntToRotation(rotation); @@ -82,16 +87,18 @@ public Coordinate getOrigin() { - short[] x = new short[4]; + rawBuffer.position(28 * 2); + ByteOrder bo = rawBuffer.order(); + rawBuffer.order(ByteOrder.BIG_ENDIAN); + byte[] rawValue = new byte[8]; - System.arraycopy(raw, 28, x, 0, 4); + rawBuffer.get(rawValue); // x + double dx = Utility.converUnitToCoord(Utility.convertDGNToIEEEDouble(rawValue)); - double dx = Utility.converUnitToCoord((int) Utility.convertDGNToIEEEDouble(x)); - short[] y = new short[4]; + rawBuffer.get(rawValue); // y + double dy = Utility.converUnitToCoord(Utility.convertDGNToIEEEDouble(rawValue)); - System.arraycopy(raw, 32, y, 0, 4); - - double dy = Utility.converUnitToCoord((int) Utility.convertDGNToIEEEDouble(y)); + rawBuffer.order(bo); return new Coordinate(dx, dy); } @@ -165,7 +172,7 @@ return instance; } - protected Element createElement(short[] raw) + protected Element createElement(byte[] raw) { return new EllipseElement(raw); } -- Gitblit v0.0.0-SNAPSHOT