In general, you have to use the CoordinateSequence.setOrdinate method to
modify CoordinateSequences. (You still have to call geometryChanged)
There is no contract saying that the Coordinate array returned by
Geometry.getCoordinates will be the same storage used by the internal
implementation. In fact, for most CoordinateSequence implementations
this will definitely not be the case, since they use a more optimized
internal storage format.
Fernando González wrote:
I think I have run into another problem related with the
PackedCoordinateSequence. I modify some geometry by modifying the
return value of Geometry.getCoordinates() and calling
Geometry.geometryChanged() just after that. The geometry is stored in
memory and regularly it "undoes" the change. I don't know exactly what
do I do to undo the change but I have been able to reproduce it by
cloning the geometry. Here you have the code. It works if I build the
geometry using a Coordinate array but it fails if I use
PackedCoordinateSequence. Is this a bug? Are there any easy workaround?
Thanks in advance,
Fernando.
// Create coordinates
PackedCoordinateSequence pcs = new
PackedCoordinateSequence.Double(2, 2);
pcs.setX(0, 4);
pcs.setY(0, 4);
pcs.setX(1, 8);
pcs.setY(1, 8);
// Create linestring
GeometryFactory gf = new GeometryFactory();
LineString ls = gf.createLineString(pcs);
// LineString ls = gf.createLineString(new Coordinate[] {
// new Coordinate(4, 4), new Coordinate(8, 8) });
// Clone it
LineString ls2 = (LineString) ls.clone();
// They are equals
System.out.println(ls.equalsExact(ls2));
// Modify first x coordinate
ls.getCoordinates()[0].x = 1000;
ls.geometryChanged();
// Clone it
ls2 = (LineString) ls.clone();
// They are not equals
System.out.println(ls.equalsExact(ls2));
------------------------------------------------------------------------
_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel