MathTransform transform = CRS.findMathTransform( crs, DefaultGeographicCRS.WGS84_3D );
Geometry geometry = transform( geom, transform );
return geometry; // The extra Z values will be ignored
} catch (FactoryException exception) {
throw new TransformException(Errors.format(
ErrorKeys.CANT_REPROJECT_$1, crs));
}
}
else if ( CRS.equalsIgnoreMetadata( crs, DefaultGeographicCRS.WGS84 ) ){
return geom;
}
else {
try {
MathTransform transform = CRS.findMathTransform( crs, DefaultGeographicCRS.WGS84 );
return transform( geom, transform );
} catch (FactoryException exception) {
throw new TransformException(Errors.format(
ErrorKeys.CANT_REPROJECT_$1, crs));
}
}
}