/*
 * Licensed Materials - Property of Rogue Wave Software, Inc. 
 * © Copyright Rogue Wave Software, Inc. 2014, 2016 
 * © Copyright IBM Corp. 2009, 2014
 * © Copyright ILOG 1996, 2009
 * All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * The Software and Documentation were developed at private expense and
 * are "Commercial Items" as that term is defined at 48 CFR 2.101,
 * consisting of "Commercial Computer Software" and
 * "Commercial Computer Software Documentation", as such terms are
 * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
 * as applicable.
 */

import ilog.views.maps.IlvCoordinate;
import ilog.views.maps.projection.IlvMercatorProjection;
import ilog.views.maps.projection.IlvProjection;
import ilog.views.maps.projection.IlvProjectionException;
import ilog.views.maps.projection.IlvProjectionUtil;
import ilog.views.util.IlvProductUtil;

public class ProjSample1 {

  static public void main(String argv[]) {
    // This sample uses JViews Maps features. When deploying an
    // application that includes this code, you need to be in possession
    // of a Rogue Wave JViews Maps Deployment license.
    IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.JViews_Maps_Deployment);

    IlvProjection projection = new IlvMercatorProjection();

    double lambda = IlvProjectionUtil.DegreeToRadian(-45D);
    double phi = IlvProjectionUtil.DegreeToRadian(30D);

    IlvCoordinate coord = new IlvCoordinate(lambda, phi);

    try {
      projection.forward(coord);
    } catch (IlvProjectionException e) {
      System.out.println("Projection exception for this data");
    }

    System.out.println("The projection of 45W 30N is ");
    System.out.println("x = " + (int) coord.x + " m");
    System.out.println("y = " + (int) coord.y + " m");

    try {
      projection.inverse(coord);
    } catch (IlvProjectionException e) {
      System.out.println("Projection exception for this data");
    }

    System.out.println("The inverse projection is ");
    System.out.println(IlvProjectionUtil.RadianToDMS(coord));
  }

}