private void transform() throws Exception {
ILayer editLayer = getMap().getEditManager().getEditLayer();
if (map.getViewportModel().getCRS().equals(editLayer.getCRS(null))) {
return;
}
MathTransform mt = CRS.findMathTransform(map.getViewportModel().getCRS(), editLayer
.getCRS(), true);
if (mt == null || mt.isIdentity()) {
return;
}
double[] coords = new double[coordinates.length * 2];
for( int i = 0; i < coordinates.length; i++ ) {
coords[i * 2] = coordinates[i].x;
coords[i * 2 + 1] = coordinates[i].y;
}
mt.transform(coords, 0, coords, 0, coordinates.length);
for( int i = 0; i < coordinates.length; i++ ) {
coordinates[i].x = coords[i * 2];
coordinates[i].y = coords[i * 2 + 1];
}
}