import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.referencing.CRS;
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.operation.MathTransform;

/*
 * Copyright 2001-2020 by Hexagon AB. All Rights Reserved
 */

/**
 * @author Gerd Müller-Schramm, 2020
 * @version 1.0
 * @since 16.5
 */
public class ApacheSISTest {

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    
    org.opengis.referencing.crs.CoordinateReferenceSystem epsg2154 = CRS.fromWKT("PROJCS[\"RGF93 / Lambert-93\",\r\n" + 
        "    GEOGCS[\"RGF93\",\r\n" + 
        "        DATUM[\"Reseau_Geodesique_Francais_1993\",\r\n" + 
        "            SPHEROID[\"GRS 1980\",6378137,298.257222101,\r\n" + 
        "                AUTHORITY[\"EPSG\",\"7019\"]],\r\n" + 
        "            TOWGS84[0,0,0,0,0,0,0],\r\n" + 
        "            AUTHORITY[\"EPSG\",\"6171\"]],\r\n" + 
        "        PRIMEM[\"Greenwich\",0,\r\n" + 
        "            AUTHORITY[\"EPSG\",\"8901\"]],\r\n" + 
        "        UNIT[\"degree\",0.0174532925199433,\r\n" + 
        "            AUTHORITY[\"EPSG\",\"9122\"]],\r\n" + 
        "        AUTHORITY[\"EPSG\",\"4171\"]],\r\n" + 
        "    PROJECTION[\"Lambert_Conformal_Conic_2SP\"],\r\n" + 
        "    PARAMETER[\"standard_parallel_1\",49],\r\n" + 
        "    PARAMETER[\"standard_parallel_2\",44],\r\n" + 
        "    PARAMETER[\"latitude_of_origin\",46.5],\r\n" + 
        "    PARAMETER[\"central_meridian\",3],\r\n" + 
        "    PARAMETER[\"false_easting\",700000],\r\n" + 
        "    PARAMETER[\"false_northing\",6600000],\r\n" + 
        "    UNIT[\"metre\",1,\r\n" + 
        "        AUTHORITY[\"EPSG\",\"9001\"]],\r\n" + 
        "    AXIS[\"X\",EAST],\r\n" + 
        "    AXIS[\"Y\",NORTH],\r\n" + 
        "    AUTHORITY[\"EPSG\",\"2154\"]]");
    org.opengis.referencing.crs.CoordinateReferenceSystem epsg28992 = CRS.fromWKT("PROJCS[\"Amersfoort / RD New\",\r\n" + 
        "    GEOGCS[\"Amersfoort\",\r\n" + 
        "        DATUM[\"Amersfoort\",\r\n" + 
        "            SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,\r\n" + 
        "                AUTHORITY[\"EPSG\",\"7004\"]],\r\n" + 
        "            TOWGS84[565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725],\r\n" + 
        "            AUTHORITY[\"EPSG\",\"6289\"]],\r\n" + 
        "        PRIMEM[\"Greenwich\",0,\r\n" + 
        "            AUTHORITY[\"EPSG\",\"8901\"]],\r\n" + 
        "        UNIT[\"degree\",0.0174532925199433,\r\n" + 
        "            AUTHORITY[\"EPSG\",\"9122\"]],\r\n" + 
        "        AUTHORITY[\"EPSG\",\"4289\"]],\r\n" + 
        "    PROJECTION[\"Oblique_Stereographic\"],\r\n" + 
        "    PARAMETER[\"latitude_of_origin\",52.15616055555555],\r\n" + 
        "    PARAMETER[\"central_meridian\",5.38763888888889],\r\n" + 
        "    PARAMETER[\"scale_factor\",0.9999079],\r\n" + 
        "    PARAMETER[\"false_easting\",155000],\r\n" + 
        "    PARAMETER[\"false_northing\",463000],\r\n" + 
        "    UNIT[\"metre\",1,\r\n" + 
        "        AUTHORITY[\"EPSG\",\"9001\"]],\r\n" + 
        "    AXIS[\"X\",EAST],\r\n" + 
        "    AXIS[\"Y\",NORTH],\r\n" + 
        "    AUTHORITY[\"EPSG\",\"28992\"]]");
    
    MathTransform t = CRS.findOperation(epsg2154, epsg28992, null).getMathTransform();
    DirectPosition c =
        t.transform(new DirectPosition2D(926713.7022916666, 7348947.025885417), null);

    System.out.println(c);
  }

}
