I am using 2.3.1. So I made some changes to convert back to 2.3.1 However
after re-reading my post I realized that I was a little sloppy in my
description. When I stated -87.0, 34.0 30 meters I meant -87.0 degrees, 34.0
degrees, and 30 meters above the spheroid. But I assuming that I could just
find the offset in meters from the origin and apply that to the matrix. If I
want to translate between the grid and lat/lon coordinates I am assuming I
would do something like the following based on your previous code where
targetCRS is the derivedCRS and base is the WGS84_3D
CoordinateOperationFactory coFactory =
FactoryFinder.getCoordinateOperationFactory(hints);
CoordinateOperation op;
try {
op = coFactory.createOperation(targetCRS, baseCRS);
MathTransform gridToGeographic = op.getMathTransform();
MathTransform geographicToGrid = gridToGeographic.inverse();
double[] input = new double[]{10.0,10.0,0};
double[] output = new double[3];
try {
gridToGeographic.transform(input,0,output,0,1);
} catch (TransformException ex) {
ex.printStackTrace();
}
System.out.println("Output ="+output[0]+", "+output[1]+",
"+output[2]);
} catch (OperationNotFoundException ex) {
ex.printStackTrace();
} catch (FactoryException ex) {
ex.printStackTrace();
} catch (NoninvertibleTransformException ex) {
ex.printStackTrace();
}
When I change the matrix to have no translation, so the grid origin should
be at 0 longitude, 0 latitude using the following
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, 0); // The X translation term
m.setElement(1, 3, 0); // The Y translation term
m.setElement(2, 3, 0); // The Z translation term
The above outputs
Output =100.0, 100.0, 0.0
It just seems to be applying the scaling from the matrix transform. My end
result is after the grid is defined and centered on the lat/lon point, Then
given a x,y grid location I can find the lat/lon, or given a lat/lon I can
find the grid location. And I can take that derived CRS and reproject it. I
think I am not understanding something simple.
Jason
Martin Desruisseaux-2 wrote:
>
> 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
>
>
--
View this message in context:
http://www.nabble.com/Newbie-Question-on-referencing-tf4014097.html#a11475626
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
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