Hi, I have an strange behavior with the WKBWriter. I'm using a WKBWriter in
3D (created like this: new WKBWriter(3)) to get byte[] representation of all
my geometries (2D and 3D) and so far it has worked perfectly. However I have
found a problem if the geometry was built using a
PackedCoordinateSequence.Double. It seems like it get the coordinates mixed
up...
I can easily workaround this and maybe it's the expected behavior since I'm
using a 3D WKBWriter with a 2D coordinate sequende, but I think it was
important to mention.
In the code I post I create two geometries (a 2D linestring and a 3D
linestring) using PCS and I run the "checkIO" test for both of them. I
repeat the operation creating the same geometries with a Coordinate[]. The
only case that it outputs false is with the 2D linestring created with PCS.
greetings,
Fernando
public static void main(String[] args) throws Exception {
PackedCoordinateSequence csBuilder = new
PackedCoordinateSequence.Double(
2, 2);
csBuilder.setOrdinate(0, 0, 184684.828125);
csBuilder.setOrdinate(1, 0, 2429882);
csBuilder.setOrdinate(0, 1, 184692.6875);
csBuilder.setOrdinate(1, 1, 2429886.5);
GeometryFactory gf = new GeometryFactory();
Geometry g2d = gf.createLineString(csBuilder);
csBuilder = new PackedCoordinateSequence.Double(2, 3);
csBuilder.setOrdinate(0, 0, 184684.828125);
csBuilder.setOrdinate(0, 1, 2429882);
csBuilder.setOrdinate(0, 2, 10);
csBuilder.setOrdinate(1, 0, 184692.6875);
csBuilder.setOrdinate(1, 1, 2429886.5);
csBuilder.setOrdinate(1, 2, 10);
Geometry g3d = gf.createLineString(csBuilder);
checkIO(g2d);
checkIO(g3d);
WKTReader reader = new WKTReader();
g2d = reader.read("MULTILINESTRING ((184684.828125 2429882, "
+ "184692.6875 2429886.5))");
g3d = reader.read("MULTILINESTRING ((184684.828125 2429882 14, "
+ "184692.6875 2429886.5 14))");
checkIO(g2d);
checkIO(g3d);
}
private static void checkIO(Geometry geometry) throws ParseException {
WKBWriter writer = new WKBWriter(3);
byte[] valuesBytes = writer.write(geometry);
Geometry readG = new WKBReader().read(valuesBytes);
System.out.println(geometry.equals(readG));
System.out.println(geometry);
System.out.println(readG);
}
_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel