jason.burks a écrit :
> I am trying to setup a grid, which would be 3-D cartesian in meters. Then I
> would like to position the origin of the grid based on a lat/lon point on
> the surface of the earth. From that point, given a cartesian location on the
> grid I could extact out the lat/lon or apply it to a projection. In essence
> I want to a create a CRS from a Cartesian grid which the origin is defined
> by some lat/lon point, then be able to transform data to the geographic
> coordinates or a projection.
> 
> Example: grid origin would be at point -87.0, 34.0, 30 meters above the
> spheroid.

In my understanding, you want to create a DerivedCRS, is it right? If so, then 
first we need to get a CartesianCS instance. You may use one of the predefined 
constants:

http://javadoc.geotools.fr/snapshot/org/geotools/referencing/cs/DefaultCartesianCS.html#field_summary

or create your own instance with more specific axis name and directions for 
example. In the example below, we will use the predefined constants.

Next, we need to define the conversion from grid coordinates to geographic (for 
example) coordinates. For example if the grid coordinate (0,0) is located at 
(-87,34) meters and if each grid cell is 10 meters width, we can create an 
affine transform (from geographic coordinates to grid coordinates):

     Matrix m = new Matrix4();
     m.setElement(0, 0, 0.1);  // The X scale term
     m.setElement(1, 1, 0.1);  // The Y scale term
     m.setElement(2, 2, 0.1);  // The Z scale term
     m.setElement(0, 3,  87);  // The X translation term
     m.setElement(1, 3, -34);  // The Y translation term
     m.setElement(2, 3, -30);  // The Z translation term

     MathTransformFactory mtFactory = 
ReferencingFactoryFinder.getMathTransformFactory(hints);
     MathTransform baseToDerived = mtFactory.createAffineTransform(m);

     // For the following, we uses some Geotools specific API
     // for convenience. It should also be possible to use
     // GeoAPI factory interfaces for more implementation
     // independance, but this is more tedious.
     OperationMethod method = new DefaultOperationMethod(baseToDerived);
     CoordinateReferenceSystem baseCRS = DefaultGeographicCRS.WGS84_3D;
     CoordinateSystem derivedCS = DefaultCartesianCS.GENERIC_3D;

     Map properties = new HashMap();
     properties.put(IdentifiedObject.NAME, "My derived CRS");
     CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(hints);
     DerivedCRS targetCRS = crsFactory.createDerivedCRS(properties, method, 
baseCRS, baseToDerived, derivedCS);



Hope it help,

        Martin

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to