* A geometry that fits this index object.
* @return Return an array of maximum 2 other indices, pointing to the 2 neighboring coordinates and edges. Can
* return null if no valid info is found (if no coordinate index is found).
*/
public TransactionGeomIndex[] getNeighbors(Geometry geometry) {
LineString lineString = getLineString(geometry);
if (lineString != null && lineString.isClosed()) {
// LinearRing geometry: goes round and round
if (coordinateIndex >= 0) {
int c1 = coordinateIndex - 1;
int c2 = coordinateIndex + 1;
if (c1 < 0) {
c1 = lineString.getNumPoints() - 2;
}
int e1 = coordinateIndex;
int e2 = coordinateIndex + 1;
if (e2 > lineString.getNumPoints() - 1) {
e2 = 1;
}
if (e1 == 0) {
e1 = lineString.getNumPoints() - 1;
}
TransactionGeomIndex i1 = new TransactionGeomIndex(this);
i1.setCoordinateIndex(c1);
i1.setEdgeIndex(e1);
TransactionGeomIndex i2 = new TransactionGeomIndex(this);