|
From: Kris G. <kge...@xe...> - 2009-07-31 09:21:46
|
Found the solution. The arraycopy did replace the first two elements,
but didn't remove the rest (original length stayed the same)
So the solution is to have a temporary new array to copy the elements
into and then replace the original
Looks like this:
public static Geometry create(GeometryFactory gf, final int GTYPE,
final int SRID, double[] point, int[] elemInfo, double[]
ordinates) {
final int L = SDO.L(GTYPE);
final int TT = SDO.TT(GTYPE);
double[] list;
double[][] lists;
CoordinateSequence coords;
if ((L == 0) && (TT == 01) && (point != null) && (elemInfo ==
null)) {
// Single Point Type Optimization
coords = SDO.coordinates(gf.getCoordinateSequenceFactory(),
GTYPE,
point);
elemInfo = new int[] { 1, ETYPE.POINT, 1 };
} else {
int element = 0;
int etype = ETYPE(elemInfo, element);
if (etype == 0) {
//complex type, search for encapsulated simpletype
int startpointCoordinates = 0;
do {
element++;
etype = ETYPE(elemInfo, element);
startpointCoordinates =
STARTING_OFFSET(elemInfo, element);
} while (etype == 0);
if (etype != -1) {
int ol = ordinates.length;
int elemsToCopy = ol - (startpointCoordinates -
1);
double[] newOrdinates = new double[elemsToCopy];
System.arraycopy(ordinates,
startpointCoordinates - 1, newOrdinates, 0, elemsToCopy);
elemInfo = new int[] { 1, ETYPE.POINT, 1 };
ordinates = newOrdinates;
}
}
coords = SDO.coordinates(gf.getCoordinateSequenceFactory(),
GTYPE,
ordinates);
}
return create(gf, GTYPE, SRID, elemInfo, 0, coords, -1);
}
Patch file is attached to this email.
Cheers Kris
|