private List<Point3d> transformDstToSrc( ICRS srcCRS, List<Point3d> points ) throws TransformationException { // transform all grid points return new CoordinateTransformer( srcCRS ).transform( getTargetCRS(), points ); }
double[] bbox = getAreaOfUseBBox(); CoordinateTransformer t = new CoordinateTransformer( this ); try { ICRS defWGS = GeographicCRS.WGS84;
/** * This method transforms the given coordinate (in the sourceCRS) into a coordinate of the targetCRS and back. * * @param coordinate * to be transformed. * @param withInverse * true if the inverse has to be calculated. * @throws TransformationException * @throws IllegalArgumentException * @throws UnknownCRSException */ public void doTransform( double[] coordinate, boolean withInverse ) throws IllegalArgumentException, TransformationException, UnknownCRSException { CoordinateTransformer ct = new CoordinateTransformer( targetCRS ); double[] in = Arrays.copyOf( coordinate, 3 ); // point to transform double[] out = new double[3]; outputPoint( "The original point in crs: " + sourceCRS.getAlias() + ": ", in, sourceCRS ); ct.transform( sourceCRS, in, out ); outputPoint( "The transformed point in crs: " + targetCRS.getAlias() + ": ", out, targetCRS ); if ( withInverse ) { // transform back to source CRS ct = new CoordinateTransformer( sourceCRS ); double[] nIn = new double[3]; ct.transform( targetCRS, out, nIn ); outputPoint( "The inversed transformed point in crs: " + sourceCRS.getAlias() + ": ", nIn, sourceCRS ); } }
/** * Creates a new {@link GML2GeometryWriter} instance. * * @param gmlStream * gml stream writer, must not be <code>null</code> */ public GML2GeometryWriter( GMLStreamWriter gmlStream ) { super( gmlStream ); this.outputCRS = gmlStream.getOutputCrs(); this.simplifier = gmlStream.getGeometrySimplifier(); IUnit crsUnits = null; if ( outputCRS != null ) { try { ICRS crs = outputCRS; crsUnits = crs.getAxis()[0].getUnits(); transformer = new CoordinateTransformer( crs ); transformedOrdinates = new double[crs.getDimension()]; // geoTransformer = new GeometryTransformer( crs ); } catch ( Exception e ) { LOG.debug( "Could not create transformer for CRS '" + outputCRS + "': " + e.getMessage() + ". Encoding will fail if a transformation is actually necessary." ); } } formatter = gmlStream.getCoordinateFormatter(); if ( formatter == null ) { formatter = new DecimalCoordinateFormatter( crsUnits ); } }
/** * Creates a new {@link GML3GeometryWriter} instance. * * @param gmlStreamWriter * gml stream writer, must not be <code>null</code> */ public GML3GeometryWriter( GMLStreamWriter gmlStreamWriter ) { super( gmlStreamWriter ); this.outputCRS = gmlStreamWriter.getOutputCrs(); this.simplifier = gmlStreamWriter.getGeometrySimplifier(); IUnit crsUnits = null; if ( outputCRS != null ) { try { ICRS crs = outputCRS; crsUnits = crs.getAxis()[0].getUnits(); transformer = new CoordinateTransformer( crs ); transformedOrdinates = new double[crs.getDimension()]; geoTransformer = new GeometryTransformer( crs ); } catch ( Exception e ) { LOG.debug( "Could not create transformer for CRS '" + outputCRS + "': " + e.getMessage() + ". Encoding will fail if a transformation is actually necessary." ); } } formatter = gmlStreamWriter.getCoordinateFormatter(); if ( formatter == null ) { formatter = new DecimalCoordinateFormatter( crsUnits ); } }