When I do a transform on a DirectPosition, the transformed
DirectPosition is created correctly, BUT the source DirectPosition gets
corrupted.
Is this just user error? (I cannot image how it could be).
I could not find a bug on this issue, and I will gladly post it as a bug
if I need to.

Thank You.

Here is a program that shows the problem:


package example;

import
org.geotools.geometry.jts.spatialschema.geometry.geometry.GeometryFactor
yImpl;
import org.geotools.referencing.FactoryFinder;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CRSFactory;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.referencing.operation.TransformException;
import org.opengis.spatialschema.geometry.DirectPosition;
import org.opengis.spatialschema.geometry.MismatchedDimensionException;

public class ShowCorruption {

        /**
         * @param args
         * @throws FactoryException 
         * @throws TransformException 
         * @throws MismatchedDimensionException 
         */
        public static void main(String[] args) throws FactoryException,
MismatchedDimensionException, TransformException {
                CRSFactory crsFactory;
                crsFactory = FactoryFinder.getCRSFactory(null);

                CoordinateReferenceSystem crs1 =
crsFactory.createFromWKT("PROJCS[\"UTM Zone 10, Northern
Hemisphere\",GEOGCS[\"WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS
84\",6378137,298.2572235630016],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwi
ch\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mer
cator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridia
n\",-123],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\"
,500000],PARAMETER[\"false_northing\",0],UNIT[\"meters\",1]]");
                CoordinateReferenceSystem crs2 =
crsFactory.createFromWKT("GEOGCS[\"WGS
84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS
84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0
,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\
"EPSG\",\"8901\"]],UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\
"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4
326\"]]");

                GeometryFactoryImpl geomFactoryCrs1 = new
GeometryFactoryImpl(crs1);
                GeometryFactoryImpl geomFactoryCrs2 = new
GeometryFactoryImpl(crs2);
                
                DirectPosition dp1 =
geomFactoryCrs1.createDirectPosition();
                DirectPosition dp2 =
geomFactoryCrs2.createDirectPosition(new double[] {44.0, -90.0});

                CoordinateOperationFactory coordOpFactory =
FactoryFinder.getCoordinateOperationFactory(null);
                CoordinateOperation op =
coordOpFactory.createOperation(crs1, crs2, null);
                
                System.out.println("dp2 ordinates before             : "
+ dp2.getOrdinate(0) + "," + dp2.getOrdinate(1));
                op.getMathTransform().transform(dp2, dp1);
                System.out.println("dp2 ordinates after              : "
+ dp2.getOrdinate(0) + "," + dp2.getOrdinate(1));
                System.out.println("dp1 (the output) ordinates after : "
+ dp2.getOrdinate(0) + "," + dp2.getOrdinate(1));
                System.out.println("which shows the output is being
corrupted byt the transform operation");
        }
}

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to