I have implemented an Equirectangular.java class as I actually require Plate
Carree
It appears correct, but I am unable to test as my testcase fails with the
following error:
Testsuite: org.geotools.referencing.operation.ProjectionTest
Tests run: 3, Failures: 0, Errors: 1, Time elapsed: 0.769 sec
Testcase:
testEquirectangular(org.geotools.referencing.operation.ProjectionTest):
Caused an ERROR
No transform for classification "Equidistant_Cylindrical".
org.opengis.referencing.NoSuchIdentifierException: No transform for
classification "Equidistant_Cylindrical".
at
org.geotools.referencing.operation.DefaultMathTransformFactory.getProvider(DefaultMathTransformFactory.java:265)
at
org.geotools.referencing.operation.DefaultMathTransformFactory.getDefaultParameters(DefaultMathTransformFactory.java:292)
at
org.geotools.referencing.operation.ProjectionTest.testEquirectangular(ProjectionTest.java:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
I'm not sure of the magic required to get the projection seen by the test case.
If you can give me relevant pointers, I will test it myself, otherwise, it is
there for you to include in the source code.
/*
* 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
* <br><br>
*
*
* @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 Andr? Gosselin
* @author Martin Desruisseaux
* @author Rueben Schulz
*/
public class Equirectangular extends MapProjection {
/**
* The [EMAIL PROTECTED]
org.geotools.referencing.operation.MathTransformProvider} for a [EMAIL
PROTECTED] org.geotools.referencing.operation.projection.Equirectangular} 1SP
projection.
*
* @see <A
HREF="http://www.remotesensing.org/geotiff/proj_list/mercator_1sp.html">"mercator_1sp"
on Remote Sensing</A>
* @see org.geotools.referencing.operation.DefaultMathTransformFactory
*
* @version $Id: Mercator.java 13922 2005-05-29 12:23:21Z desruisseaux $
* @author Martin Desruisseaux
* @author Rueben Schulz
*/
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_Plate_Carree"),
new NamedIdentifier(CitationImpl.GEOTOOLS,
Resources.formatInternational(
ResourceKeys.EQUIDISTANT_PROJECTION))
}, new ParameterDescriptor[] {
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);
}
}
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("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);
}
John Grange
Senior Software Engineer
Tel: +44 (0)1749 834922
email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
BlueFinger Limited
Underwood Business Park
Wookey Hole Road, WELLS. BA5 1AF
Tel: +44 (0)1749 834900
Fax: +44 (0)1749 834901
web: www.bluefinger.com
Company Reg No: 4209395 Underwood Business Park, Wookey Hole Road, Wells,
Somerset BA5 1AF.
*** This E-mail contains confidential information for the addressee only. If
you are not the intended recipient, please notify us immediately. You should
not use, disclose, distribute or copy this communication if received in error.
No binding contract will result from this e-mail until such time as a written
document is signed on behalf of the company. BlueFinger Limited cannot accept
responsibility for the completeness or accuracy of this message as it has been
transmitted over public networks.***
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Martin Desruisseaux
Sent: Monday, October 03, 2005 11:40 PM
To: John C Cartwright
Cc: [email protected]
Subject: Re: [Geotools-gt2-users] problem creating Plate Carree
CoordinateReferenceSystem from WKT
John C Cartwright a écrit :
> I'm getting a
>
> NoSuchIdentifierException: No transform for classification "Equirectangular"
>
> exception in trying to create a Plate Carree or Equirectangular
> projected coordinate system. I thought "Plate_Carree" was a valid EPSG
> identifier, but I'm certain that "Equirectangular" is. Can anyone tell
> me what I'm doing wrong in the code below. Full stack trace at the end
> of the message.
The formulas for "Equirectangular" are not yet implemented in Geotools
(the transformation formulas need to be implemented in Java, they can't
be inferred automatically from the EPSG database). Currently implemented
projections can be listed from SVN:
http://svn.geotools.org/geotools/trunk/gt/module/referencing/src/org/geotools/referencing/operation/projection/
On the bright side, adding a new projetion is not really hard.
Developpers can copy-and-paste the Mercator.java class in the
above-cited link, and replace the transformNormalized(...) and
inverseTransformNormalized(...) method body by the new projection code
(ported for example from the Proj4 C library). The most tedious (but
very important) part is to test the projection.
If there is a volunter on geotools mailing list whiling to send me a
Equirectangular.java class with correct transformNormalized(...)
methods, and whiling to test it, I would be happy to make the
integration in Geotools.
-------------------------------------------------------------------
Note: (to be more accurate)
For building CRS, Geotools take most of its informations in the EPSG
database. The most important exception (by far) is the table
OperationMethod. Informations that appears in the EPSG OperationMethods
table are used, but are not suffisient. The actual method must also be
hard coded in Java, since it is about numerical computation. Supported
OperationMethods can be listed by the following command line:
java org.geotools.referencing.operation.DefaultMathTransformFactory
Windows users may need to provide an "-encoding 850" argument in order
to get a proper output, where "850" is the number displayed by the
"chcp" DOS command.
Martin.
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users