Hello,

We are running the unit test below. It works except the output coordinates
are inverted. How can we tell (if we decide not to use
AbstractCRS.castOrCopy)?

In the example below, the axis for the target CRS tells us X is first, yet
it seems to be Y first in the result. What am I missing?

   @Test
    public void test1() throws FactoryException,
MismatchedDimensionException, TransformException  {
       CoordinateReferenceSystem targetCRS = CRS.forCode("EPSG:2940");
//Pulkovo 1942 / CS63 zone K3
        CoordinateReferenceSystem wgs84 = CRS.forCode("EPSG:4326");

        double inputLat  = 46;
        double inputLong = 53;

        double outputX = 3240705.59565832;
        double outputY = 5081705.3100662;

        CoordinateOperation operation = CRS.findOperation(wgs84, targetCRS,
null);

        System.out.println("Order for WGS84 = " +
wgs84.getCoordinateSystem().getAxis(0).getAbbreviation()); // shows Lat
first
        DirectPosition position = new DirectPosition2D(inputLat, inputLong);
        double[] coordinate =
operation.getMathTransform().transform(position, position).getCoordinate();

        System.out.println("Order for 2940 = " +
targetCRS.getCoordinateSystem().getAxis(0).getAbbreviation());  // shows X
first

        // order seems to be Y, X
        Assert.assertEquals(outputX, coordinate[1], 5);
        Assert.assertEquals(outputY, coordinate[0], 5);
    }

Reply via email to