if (gridShift == null) { // Create grid when first needed.
try {
gridShift = FACTORY.createNTv2Grid(gridLocation);
} catch (FactoryException e) {
throw new TransformException("NTv2 Grid " + gridLocation +
" Could not be created", e);
}
}
try {
GridShift shift = new GridShift();
while(--numPts >= 0) {
shift.setLonPositiveEastDegrees(srcPts[srcOff++]);
shift.setLatDegrees(srcPts[srcOff++]);
if (forward) {
shifted = gridShift.gridShiftForward(shift);
} else {
shifted = gridShift.gridShiftReverse(shift);
}
if (shifted) {
dstPts[dstOff++]=shift.getShiftedLonPositiveEastDegrees();
dstPts[dstOff++]=shift.getShiftedLatDegrees();
} else {
if(LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Point (" + srcPts[srcOff-2] + ", " + srcPts[srcOff-1] +
") is not covered by '" + this.grid + "' NTv2 grid," +
" it will not be shifted.");
}
dstPts[dstOff++]=srcPts[srcOff-2];
dstPts[dstOff++]=srcPts[srcOff-1];
}
}
} catch (IOException e) {
throw new TransformException(e.getLocalizedMessage(), e);
}
}