blob: afd4989f9dc6703b01abf52a689ebc7f656c1301 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.stem.loggers.imagewriter.logger.projections;
import java.awt.geom.Rectangle2D;
/**
* Implementation of Equirectangular map projection.
* In terms of the existing coordinate system implied
* in the Globe system, this projection does nothing as
* this is the implied base coordinate system
*
* @see http://mathworld.wolfram.com/EquirectangularProjection.html
*
*/
public class Mercator implements IMapProjection
{
public static final double MAX_LAT = 85.05113;
public static final double MIN_LAT = -85.05113;
public static final Rectangle2D PROJECTION_BOUNDS = new Rectangle2D.Double(-180.0, -180.0, 360.0, 360.0);
/**
*
*/
public Mercator()
{
super();
}
/* (non-Javadoc)
* @see com.ibm.almaden.omniglobe.projection.IMapProjection#project(java.awt.geom.Point2D)
*/
public double[] project(double lat, double lon)
{
if (Math.abs(lat) > MAX_LAT) {
return null;
}
double latR = Math.toRadians(lat);
latR = Math.toDegrees(Math.log(Math.tan(latR)+1.0/Math.cos(latR)));
return new double[] {latR,lon};
}
/* (non-Javadoc)
* @see com.ibm.almaden.omniglobe.projection.IMapProjection#project(java.awt.geom.Point2D, java.awt.geom.Point2D, boolean)
*/
public double[] project(double lat, double lon, double lat0, double lon0, boolean distort)
{
return project(lat,lon);
}
/* (non-Javadoc)
* @see com.ibm.almaden.omniglobe.projection.IMapProjection#inverseProject(java.awt.geom.Point2D)
*/
public double[] inverseProject(double lat, double lon)
{
return new double[] {lat,lon};
}
/* (non-Javadoc)
* @see com.ibm.almaden.omniglobe.projection.IMapProjection#inverseProject(java.awt.geom.Point2D, java.awt.geom.Point2D, boolean)
*/
public double[] inverseProject(double lat, double lon, double lat0, double lon0, boolean distort)
{
return inverseProject(lat, lon);
}
/* (non-Javadoc)
* @see com.ibm.almaden.omniglobe.projection.IMapProjection#setOrigin(java.awt.geom.Point2D)
*/
public void setOrigin(double lat, double lon)
{
//projection is not origin-dependent
//does nothing
}
/* (non-Javadoc)
* @see com.ibm.almaden.omniglobe.projection.IMapProjection#getBounds()
*/
public Rectangle2D getBounds()
{
return PROJECTION_BOUNDS;
}
}