/* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2005-2008, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotools.referencing.operation.projection; import java.util.Collection; import java.awt.geom.Point2D; import org.opengis.parameter.GeneralParameterDescriptor; import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterNotFoundException; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.ReferenceIdentifier; import org.geotools.math.Complex; import org.geotools.referencing.NamedIdentifier; import org.geotools.metadata.iso.citation.Citations; import static java.lang.Math.*; /** * The NZMG (New Zealand Map Grid) projection. *
* This is an implementation of algorithm published by * Land Information New Zealand. * The algorithm is documented here. *
* Implementation note
* This class make extensive use of {@link Complex} type which may be costly unless the compiler
* can inline on the stack. We assume that Jave 6 and above can do this optimization.
*
* @since 2.2
*
* @source $URL$
* @version $Id$
* @author Justin Deoliveira
* @author Martin Desruisseaux
*/
public class NewZealandMapGrid extends MapProjection {
/**
* For compatibility with different versions during deserialization.
*/
private static final long serialVersionUID = 8394817836243729133L;
/**
* Coefficients for forward and inverse projection.
*/
private static final Complex[] A = {
new Complex( 0.7557853228, 0.0 ),
new Complex( 0.249204646, 0.003371507 ),
new Complex( -0.001541739, 0.041058560 ),
new Complex( -0.10162907, 0.01727609 ),
new Complex( -0.26623489, -0.36249218 ),
new Complex( -0.6870983, -1.1651967 )
};
/**
* Coefficients for inverse projection.
*/
private static final Complex[] B = {
new Complex( 1.3231270439, 0.0 ),
new Complex( -0.577245789, -0.007809598 ),
new Complex( 0.508307513, -0.112208952 ),
new Complex( -0.15094762, 0.18200602 ),
new Complex( 1.01418179, 1.64497696 ),
new Complex( 1.9660549, 2.5127645 )
};
/**
* Coefficients for inverse projection.
*/
private static final double[] TPHI = new double[] {
1.5627014243, 0.5185406398, -0.03333098, -0.1052906, -0.0368594, 0.007317,
0.01220, 0.00394, -0.0013
};
/**
* Coefficients for forward projection.
*/
private static final double[] TPSI = new double[] {
0.6399175073, -0.1358797613, 0.063294409, -0.02526853, 0.0117879,
-0.0055161, 0.0026906, -0.001333, 0.00067, -0.00034
};
/**
* Constructs a new map projection with default parameter values.
*/
protected NewZealandMapGrid() {
this(Provider.PARAMETERS.createValue());
}
/**
* Constructs a new map projection from the supplied parameters.
*
* @param parameters The parameter values in standard units.
* @throws ParameterNotFoundException if a mandatory parameter is missing.
*/
protected NewZealandMapGrid(final ParameterValueGroup parameters)
throws ParameterNotFoundException
{
super(parameters);
}
/**
* {@inheritDoc}
*/
public ParameterDescriptorGroup getParameterDescriptors() {
return Provider.PARAMETERS;
}
/**
* Must be overridden because {@link Provider} uses instances of
* {@link ModifiedParameterDescriptor}. This hack was needed because the New Zeland map
* projection uses particular default values for parameters like "False Easting", etc.
*/
@Override
final boolean isExpectedParameter(final Collection