We are having very good success with the library and its accuracy is
excellent. A few Nad27 tests give us a bit less accurate answers but one in
particular seems to give a completely wrong result. The code has a similar
structure to what we have showed you before and we have triple checked the
parameters and the area of use. What are we doing wrong?

junit.framework.AssertionFailedError: expected:<-6563041.72105857> but
was:<-1.4544147714505669E7>

public void Transform2964_1250_Test() throws FactoryException,
MismatchedDimensionException, TransformException {
        double latitude = 52;
        double longitude = 176;
        double x = -6563041.72105857;
        double y = 2233540.23812641;
        CRSAuthorityFactory crsFactory = CRS.getAuthorityFactory("EPSG");
        CoordinateOperationAuthorityFactory opFactory =
(CoordinateOperationAuthorityFactory) crsFactory;

        // This is the transformation we want to go from Nad27 to WGS84 -
NAD_1927_To_WGS_1984_22
        CoordinateOperation datumOperation =
opFactory.createCoordinateOperation("1250");

        // NAD_1927_Alaska_Albers_Feet
        CoordinateReferenceSystem targetCRS =
crsFactory.createCoordinateReferenceSystem("2964");

        // normalize the axis for the target
        targetCRS =
AbstractCRS.castOrCopy(targetCRS).forConvention(AxesConvention.DISPLAY_ORIENTED);

        CoordinateOperation targetOperation =
CRS.findOperation(datumOperation.getSourceCRS(), targetCRS, null);

        /*
         * We have two operations: WGS84 -> Nad27 and Nad27 to X,Y to
concatenate
         */
        MathTransform step1 = datumOperation.getMathTransform().inverse();
        MathTransform step2 = targetOperation.getMathTransform();

        MathTransform completeTransform = MathTransforms.concatenate(step1,
step2);

        /*
         * transform to x,y in one step
         */
        DirectPosition source = new DirectPosition2D(latitude, longitude);
        DirectPosition target = completeTransform.transform(source, null);

        double[] coordinate = target.getCoordinate();

        Assert.assertEquals(x, coordinate[0], 10);
        Assert.assertEquals(y, coordinate[1], 10);
    }

Reply via email to