Sunburned Surveyor a écrit :
> Could you tell me where I would look in
> GeoTools to find out more about how the MathTransforms are calculated
> for the source and target CoordinateReferenceSystems.
> 
> All I really know at this point is that you provide the GeoTools API
> with two ESPG codes and it "magically" returns a MathTransformation.

The last sentence is halfly accurate, since there is two classes involved:


org.geotools.referencing.operation.DefaultCoordinateOperationFactory
--------------------------------------------------------------------
Takes two CRS objects and returns a CoordinateOperationFactory. It needs fully
formed CRS object; it can not do anything from EPSG codes alone. This class try
to apply some logic in order to find a transformation path from 'sourceCRS' to
'targetCRS'.


org.opengis.referencing.operation.CoordinateOperationAuthorityFactory
---------------------------------------------------------------------
This interface is the opposite of the former: it expects two EPSG codes, not CRS
objects. The implementation of this interface has no "intelligent" logic. It
just checks if a transformation path is explicitly defined in the EPSG database
between those two CRS. If no transformation path is explicitly defined; it
doesn't try to find one. It just returns null (or throws an exception, I don't
remember).



In addition, we have:

org.geotools.referencing.operation.AuthorityBackedFactory
---------------------------------------------------------
(or something like that; not sure about the exact name). First queries a
CoordinateOperationAuthorityFactory in order to find if a transformation path is
explicitly defined in the EPSG database. If none are found, only then it
fallback on the DefaultCoordinateOperationFactory algorithm, which tries to find
a transformation path alone by applying some rules.



> What if I wanted to add support for a custom or new Map projection?

Create a MapProjection subclass. The easiest way is to copy one of the
org.geotools.referencing.operation.projection classes (choose a simple one, for
example Equidistant) and modify it. Next, declare it in a
META-INF/services/org.geotools.referencing.operation.MathTransformProvider (from
memory) file - looks at the Geotools file for a model. You don't need to modify
any Geotools file; just put the above in your JAR. Just having your JAR in the
classpath is suffisient to get Geotools to recognize it.



> What if there was a mistake in the generated MathTransformation that I
> wanted to fix?

There is no easy mechanism right now for overriding the MathTransform computed
by DefaultCoordinateOperationFactory. However you could create your own
implementation of CoordinateOperationFactory, declares it in a META-INF/services
file in a way similar to map projection, give it a higher priority level than
the default Geotools one, and Geotools should use your implementation 
system-wide.

        Martin

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to