[Java-collab] Re: [Geotools-devel] GeoTools moving forward

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Fri Oct 10 14:32:07 EDT 2008


Sunburned Surveyor a écrit :
> I'd like to share some thoughts on the referencing module. I'm
> wondering if this new situation that has developed would be an
> opportunity to introduce a common interface that could be used for
> coordinate transformations.

Those interfaces already exist in GeoAPI. This is the MathTransform interface:

http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/operation/MathTransform.html

This interface is derived from OGC 01-009 specification (OpenGIS Coordinate
Transformation Service Implementation Specification):

http://www.opengeospatial.org/standards/ct



> public abstract void setSourceCrs(String argSourceCrs);
> 
> public abstract void setDestinationCrs(String argDestinationCrs);
> 
> public abstract double[] transformCoordinate(double[] coordinate);


Using GeoAPI interfaces (all derived from OGC specifications, let me remind),
you would process as below:

CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT("...");
CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT("...");
MathTransform mt = coordinateOperationFactory.createOperation(sourceCRS,
targetCRS).getMathTransform():
mt.transform(coordinates, 0, coordinates, 0, numPoints);

If it is too verbose, a trivial helper class could be created with the above
API. But it would be just a convenience class delegating the work to the 4 above
lines.

	Martin


More information about the Java-collab mailing list