@@ -0,0 +1,2786 @@
+package _2_projections;%0A%0Aimport com.vividsolutions.jts.geom.Coordinate;%0Aimport org.geotools.geometry.DirectPosition2D;%0Aimport org.geotools.geometry.jts.JTS;%0Aimport org.geotools.referencing.CRS;%0Aimport org.junit.Test;%0Aimport org.opengis.geometry.DirectPosition;%0Aimport org.opengis.referencing.FactoryException;%0Aimport org.opengis.referencing.crs.CoordinateReferenceSystem;%0Aimport org.opengis.referencing.operation.MathTransform;%0Aimport org.opengis.referencing.operation.TransformException;%0A%0Aimport java.util.Arrays;%0A%0A/**%0A * @author Jesse on 3/23/2015.%0A */%0Apublic class _2_TransformPoint %7B%0A    @Test%0A    public void testDirectPosition() throws FactoryException, TransformException %7B%0A        CoordinateReferenceSystem wgs84 = CRS.decode(%22EPSG:4326%22);%0A        CoordinateReferenceSystem epsg2154 = CRS.decode(%22EPSG:2154%22);%0A        final MathTransform mathTransform = CRS.findMathTransform(wgs84, epsg2154, true);%0A%0A        DirectPosition2D point2 = new DirectPosition2D(1, 52);%0A        DirectPosition transformedPoint = mathTransform.transform(point2, new DirectPosition2D(epsg2154));%0A        System.out.println(%22Start: %22 + point2 + %22 end: %22 + transformedPoint);%0A%0A        DirectPosition back = mathTransform.inverse().transform(point2, new DirectPosition2D(wgs84));%0A        System.out.println(%22back: %22 + back);%0A    %7D%0A%0A    @Test%0A    public void testCoordinate() throws FactoryException, TransformException %7B%0A        CoordinateReferenceSystem wgs84 = CRS.decode(%22EPSG:4326%22);%0A        CoordinateReferenceSystem epsg2154 = CRS.decode(%22EPSG:2154%22);%0A        final MathTransform mathTransform = CRS.findMathTransform(wgs84, epsg2154, true);%0A%0A        Coordinate startPoint = new Coordinate(1, 52);%0A        final Coordinate transformed = JTS.transform(startPoint, new Coordinate(), mathTransform);%0A        System.out.println(%22Start: %22 + startPoint + %22 end: %22 + transformed);%0A%0A        final Coordinate back = JTS.transform(startPoint, new Coordinate(), mathTransform.inverse());%0A        System.out.println(%22back: %22 + back);%0A    %7D%0A    @Test%0A    public void testArray() throws FactoryException, TransformException %7B%0A        CoordinateReferenceSystem wgs84 = CRS.decode(%22EPSG:4326%22);%0A        CoordinateReferenceSystem epsg2154 = CRS.decode(%22EPSG:2154%22);%0A        final MathTransform mathTransform = CRS.findMathTransform(wgs84, epsg2154, true);%0A%0A        final double%5B%5D srcPts = %7B1, 52%7D;%0A        final double%5B%5D dstPts = new double%5B2%5D;%0A        mathTransform.transform(srcPts, 0, dstPts, 0, 1);%0A        System.out.println(%22Start: %22 + Arrays.toString(srcPts) + %22 End: %22 + Arrays.toString(dstPts));%0A%0A        final double%5B%5D wgs84AgainPts = new double%5B2%5D;%0A        mathTransform.inverse().transform(dstPts, 0, wgs84AgainPts, 0, 1);%0A%0A        System.out.println(%22back: %22 + Arrays.toString(wgs84AgainPts));%0A%0A    %7D%0A%0A%7D%0A

Add transform point