org.geotools.referencing.operation.projection
Class NewZealandMapGrid

java.lang.Object
  extended byorg.geotools.referencing.wkt.Formattable
      extended byorg.geotools.referencing.operation.transform.AbstractMathTransform
          extended byorg.geotools.referencing.operation.projection.MapProjection
              extended byorg.geotools.referencing.operation.projection.NewZealandMapGrid
All Implemented Interfaces:
org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.MathTransform2D, java.io.Serializable

public class NewZealandMapGrid
extends MapProjection

Implementation of the NZMG (New Zealand Map Grid) projection.

This is an implementation of algorithm published by Land Information New Zealand. The algorithm is documented here.

Since:
2.2
Version:
$Id: NewZealandMapGrid.java 18048 2006-02-16 02:35:17Z desruisseaux $
Author:
Justin Deoliveira, Martin Desruisseaux
See Also:
Serialized Form
To Do:
The algorithm uses complex numbers, which is not very well supported in Java. This implementation uses Complex as a support class. Various instances of Complex are created once for ever at construction time, in order to avoid creating up to 6 objects for every point to be projected. The downside is that transformation methods must be synchronized. The cost should be small for simple applications, but may become important for multi-thread applications. Furthermore, those fields raise a slight serialization issue.

The most efficient fix in Java would be to expand inline all Complex operations like add (easy), multiply (more tedious), etc., until we get a code using only primitives on the stack and no Complex objects on the heap (except the and constants). But it would make the code significantly more complex and difficult to read.

An elegant fix would have been "lightweight objects" allocated on the stack (something similar to in C#), if such thing existed in the Java language.


Nested Class Summary
static class NewZealandMapGrid.Provider
          The MathTransformProvider for New Zealand Map Grid.
 
Nested classes inherited from class org.geotools.referencing.operation.projection.MapProjection
MapProjection.AbstractProvider
 
Field Summary
 
Fields inherited from class org.geotools.referencing.operation.projection.MapProjection
centralMeridian, excentricity, excentricitySquared, falseEasting, falseNorthing, globalScale, isSpherical, latitudeOfOrigin, scaleFactor, semiMajor, semiMinor
 
Constructor Summary
protected NewZealandMapGrid()
          Constructs a new map projection with default parameter values.
protected NewZealandMapGrid(org.opengis.parameter.ParameterValueGroup parameters)
          Constructs a new map projection from the supplied parameters.
 
Method Summary
 org.opengis.parameter.ParameterDescriptorGroup getParameterDescriptors()
          Returns the parameter descriptors for this map projection. This is used for a providing a default implementation of MapProjection.getParameterValues(), as well as arguments checking.
protected  java.awt.geom.Point2D inverseTransformNormalized(double x, double y, java.awt.geom.Point2D ptDst)
          Transforms the specified (x,y) coordinate and stores the result in .
protected  java.awt.geom.Point2D transformNormalized(double x, double y, java.awt.geom.Point2D ptDst)
          Transforms the specified (x,y) coordinate (units in radians) and stores the result in (linear distance on a unit sphere).
 
Methods inherited from class org.geotools.referencing.operation.projection.MapProjection
equals, getParameterValues, getSourceDimensions, getTargetDimensions, getToleranceForAssertions, hashCode, inverse, transform, transform, transform
 
Methods inherited from class org.geotools.referencing.operation.transform.AbstractMathTransform
createTransformedShape, derivative, derivative, ensureNonNull, formatWKT, getDimSource, getDimTarget, isIdentity, needCopy, rollLongitude, transform
 
Methods inherited from class org.geotools.referencing.wkt.Formattable
toString, toWKT, toWKT, toWKT
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.referencing.operation.MathTransform2D
createTransformedShape, derivative
 
Methods inherited from interface org.opengis.referencing.operation.MathTransform
derivative, isIdentity, toWKT, transform
 

Constructor Detail

NewZealandMapGrid

protected NewZealandMapGrid()
Constructs a new map projection with default parameter values.


NewZealandMapGrid

protected NewZealandMapGrid(org.opengis.parameter.ParameterValueGroup parameters)
                     throws org.opengis.parameter.ParameterNotFoundException
Constructs a new map projection from the supplied parameters.

Parameters:
parameters - The parameter values in standard units.
Throws:
org.opengis.parameter.ParameterNotFoundException - if a mandatory parameter is missing.
Method Detail

getParameterDescriptors

public org.opengis.parameter.ParameterDescriptorGroup getParameterDescriptors()
Returns the parameter descriptors for this map projection. This is used for a providing a default implementation of MapProjection.getParameterValues(), as well as arguments checking.

Specified by:
getParameterDescriptors in class MapProjection

transformNormalized

protected java.awt.geom.Point2D transformNormalized(double x,
                                                    double y,
                                                    java.awt.geom.Point2D ptDst)
                                             throws ProjectionException
Transforms the specified (x,y) coordinate (units in radians) and stores the result in (linear distance on a unit sphere).

Specified by:
transformNormalized in class MapProjection
Parameters:
x - The longitude of the coordinate, in radians.
y - The latitude of the coordinate, in radians.
ptDst - the specified coordinate point that stores the result of transforming , or . Ordinates will be in a dimensionless unit, as a linear distance on a unit sphere or ellipse.
Returns:
the coordinate point after transforming , and storing the result in .
Throws:
ProjectionException - if the point can't be transformed.

inverseTransformNormalized

protected java.awt.geom.Point2D inverseTransformNormalized(double x,
                                                           double y,
                                                           java.awt.geom.Point2D ptDst)
                                                    throws ProjectionException
Transforms the specified (x,y) coordinate and stores the result in .

Specified by:
inverseTransformNormalized in class MapProjection
Parameters:
x - The easting of the coordinate, linear distance on a unit sphere or ellipse.
y - The northing of the coordinate, linear distance on a unit sphere or ellipse.
ptDst - the specified coordinate point that stores the result of transforming , or . Ordinates will be in radians.
Returns:
the coordinate point after transforming , and storing the result in .
Throws:
ProjectionException - if the point can't be transformed.


Copyright © GeoTools. All Rights Reserved.