Martin,
Thanks for the help - The new projection now works. The initial poster's WKT
works, as does EPSG:32662
Please will you add it to the source tree (preferably in 2.1.x as that is where
I tested it and am using it).
Details of the changes are outlined below:
Regards,
John Grange
The new line for the
META-INF/services/org.geotools.referencing/operation.MathTransformProvider is:
org.geotools.referencing.operation.projection.Equirectangular$ProviderEquirectangular
The test case is in org.geotools.referencing.operation.ProjectionTest.java and
is:
public void testEquirectangular() throws FactoryException,
TransformException {
///////////////////////////////////////
// Equidistant_Cylindrical tests //
///////////////////////////////////////
if (VERBOSE) {
printParameters("Equidistant_Cylindrical");
}
MathTransform transform;
ParameterValueGroup params;
// approx bristol UK
params = mtFactory.getDefaultParameters("Equidistant_Cylindrical");
params.parameter("semi_major") .setValue(6378137);
params.parameter("semi_minor") .setValue(6378137);
params.parameter("central_meridian").setValue( 0.000);
params.parameter("latitude_of_origin").setValue( 0.000);
params.parameter("false_easting") .setValue(0.0 );
params.parameter("false_northing") .setValue(0.0 );
transform = mtFactory.createParameterizedTransform(params);
if (VERBOSE) {
System.out.println(transform);
}
doTransform(new DirectPosition2D(-2.5, 51.37),
new DirectPosition2D(-278298.73, 5718482.24), transform);
}
and the code for org.geotools.referencing.operation.projection.Equirectangular
is:
/*
* Geotools 2 - OpenSource mapping toolkit
* (C) 2003, Geotools Project Managment Committee (PMC)
* (C) 2001, Institut de Recherche pour le D?veloppement
* (C) 1999, Fisheries and Oceans Canada
*
* 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; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* This package contains formulas from the PROJ package of USGS.
* USGS's work is fully acknowledged here.
*/
package org.geotools.referencing.operation.projection;
// J2SE dependencies and extensions
import java.awt.geom.Point2D;
import java.util.Collection;
import javax.units.NonSI;
// OpenGIS dependencies
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.operation.CylindricalProjection;
import org.opengis.referencing.operation.MathTransform;
// Geotools dependencies
import org.geotools.measure.Latitude;
import org.geotools.metadata.iso.citation.CitationImpl;
import org.geotools.referencing.NamedIdentifier;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.resources.cts.Resources;
/**
* Equirectangular Projection (used in, for example, WGS84 / Plate Carree
(EPSG:32662) - Multiple names are used for this projection,
* such as Equirectangular, Cylindrical Equidistant and Plate Carree
* <br><br>
* Adapeted from Mercator projection class.
*
*
* @see <A
HREF="http://mathworld.wolfram.com/CylindricalEquidistantProjection.html">Mercator
projection on MathWorld</A>
* @see <A
HREF="http://www.remotesensing.org/geotiff/proj_list/equirectangular.html">Equirectangular</A>
*
* @version $Id$
* @author John Grange
*/
public class Equirectangular extends MapProjection {
/**
* The [EMAIL PROTECTED]
org.geotools.referencing.operation.MathTransformProvider} for a [EMAIL
PROTECTED] org.geotools.referencing.operation.projection.Equirectangular}
*
* @see org.geotools.referencing.operation.DefaultMathTransformFactory
*
* @version $Id$
* @author John Grange
*/
public static final class ProviderEquirectangular extends AbstractProvider {
/**
* The parameters group.
*/
static final ParameterDescriptorGroup PARAMETERS =
createDescriptorGroup(new NamedIdentifier[] {
new NamedIdentifier(CitationImpl.OGC,
"Equidistant_Cylindrical"),
new NamedIdentifier(CitationImpl.EPSG, "Equidistant
Cylindrical"),
new NamedIdentifier(CitationImpl.EPSG, "9823"),
new NamedIdentifier(CitationImpl.GEOTIFF,
"CT_Equirectangular"),
new NamedIdentifier(CitationImpl.GEOTOOLS,
"Equidistant_Cylindrical")
}, new ParameterDescriptor[] {
SEMI_MAJOR, SEMI_MINOR,
LATITUDE_OF_ORIGIN,
CENTRAL_MERIDIAN,
FALSE_EASTING,
FALSE_NORTHING
});
/**
* Constructs a new provider.
*/
public ProviderEquirectangular() {
super(PARAMETERS);
}
/**
* Returns the operation type for this map projection.
*/
protected Class getOperationType() {
return CylindricalProjection.class;
}
/**
* Creates a transform from the specified group of parameter values.
*
* @param parameters The group of parameter values.
* @return The created math transform.
* @throws org.opengis.parameter.ParameterNotFoundException if a
required parameter was not found.
*/
public MathTransform createMathTransform(final ParameterValueGroup
parameters)
throws ParameterNotFoundException
{
final Collection descriptors = PARAMETERS.descriptors();
return new Equirectangular (parameters, descriptors);
}
}
/**
* Constructs a new map projection from the supplied parameters.
*
* @param parameters The parameter values in standard units.
* @throws org.opengis.parameter.ParameterNotFoundException if a mandatory
parameter is missing.
*/
protected Equirectangular(final ParameterValueGroup parameters)
throws ParameterNotFoundException
{
this(parameters, getDescriptor(parameters).descriptors());
}
/**
* Work around for RFE #4093999 in Sun's bug database
* ("Relax constraint on placement of this()/super() call in constructors").
*/
private static ParameterDescriptorGroup getDescriptor(final
ParameterValueGroup parameters) {
return ProviderEquirectangular.PARAMETERS;
}
/**
* Constructs a new map projection from the supplied parameters.
*
* @param parameters The parameter values in standard units.
* @param expected The expected parameter descriptors.
* @throws org.opengis.parameter.ParameterNotFoundException if a mandatory
parameter is missing.
*/
Equirectangular(final ParameterValueGroup parameters, final Collection
expected)
throws ParameterNotFoundException
{
//Fetch parameters
super(parameters, expected);
}
/**
* [EMAIL PROTECTED]
*/
public ParameterDescriptorGroup getParameterDescriptors() {
return ProviderEquirectangular.PARAMETERS;
}
/**
* [EMAIL PROTECTED]
*/
public ParameterValueGroup getParameterValues() {
final ParameterValueGroup values = super.getParameterValues();
return values;
}
/**
* Transforms the specified (<var>x</var>,<var>y</var>) coordinate (units
in radians)
* and stores the result in <code>ptDst</code> (linear distance on a unit
sphere).
*/
protected Point2D transformNormalized(double x, double y, final Point2D
ptDst)
throws ProjectionException
{
x = x * Math.cos(latitudeOfOrigin);
if (ptDst != null) {
ptDst.setLocation(x,y);
return ptDst;
}
return new Point2D.Double(x,y);
}
/**
* Transforms the specified (<var>x</var>,<var>y</var>) coordinate
* and stores the result in <code>ptDst</code>.
*/
protected Point2D inverseTransformNormalized(double x, double y, final
Point2D ptDst)
throws ProjectionException
{
x = x / Math.cos(latitudeOfOrigin);
if (ptDst != null) {
ptDst.setLocation(x,y);
return ptDst;
}
return new Point2D.Double(x,y);
}
}
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users