Search in sources :

Example 1 with LambertConformalWest

use of org.apache.sis.internal.referencing.provider.LambertConformalWest in project sis by apache.

the class LambertConicConformalTest method testLambertConicConformalWestOrientated.

/**
 * Tests the <cite>"Lambert Conic Conformal (1SP West Orientated)"</cite> case (EPSG:9826)).
 *
 * @throws FactoryException if an error occurred while creating the map projection.
 * @throws TransformException if an error occurred while projecting a coordinate.
 */
@Test
@DependsOnMethod("testLambertConicConformal1SP")
public void testLambertConicConformalWestOrientated() throws FactoryException, TransformException {
    createCompleteProjection(new LambertConformal1SP(), // Semi-major axis length
    WGS84_A, // Semi-minor axis length
    WGS84_B, // Central meridian
    0.5, // Latitude of origin
    40, // Standard parallel 1
    NaN, // Standard parallel 2
    NaN, // Scale factor
    0.997, // False easting
    200, // False northing
    100);
    final MathTransform reference = transform;
    createCompleteProjection(new LambertConformalWest(), // Semi-major axis length
    WGS84_A, // Semi-minor axis length
    WGS84_B, // Central meridian
    0.5, // Latitude of origin
    40, // Standard parallel 1
    NaN, // Standard parallel 2
    NaN, // Scale factor
    0.997, // False easting
    200, // False northing
    100);
    final Random random = TestUtilities.createRandomNumberGenerator();
    final double[] sources = new double[20];
    for (int i = 0; i < sources.length; ) {
        // Longitude
        sources[i++] = 20 * random.nextDouble();
        // Latitude
        sources[i++] = 10 * random.nextDouble() + 35;
    }
    final double[] expected = new double[sources.length];
    reference.transform(sources, 0, expected, 0, sources.length / 2);
    /*
         * At this point, we have the source coordinates and the expected projected coordinates calculated
         * by the "Lambert Conic Conformal (1SP)" method. Now convert those projected coordinates into the
         * coordinates that we expect from the "Lambert Conic Conformal (1SP West Orientated)".  If we had
         * no false easting, we would just revert the sign of 'x' values. But because of the false easting,
         * we expect an additional offset of two time that easting. This is because (quoting the EPSG guide):
         *
         *    the term FE retains its definition, i.e. in the Lambert Conic Conformal (West Orientated)
         *    method it increases the Westing value at the natural origin.
         *    In this method it is effectively false westing (FW).
         *
         * So the conversion for this test case should be:     W = 400 - E
         *
         * However our map projection "kernel" implementation does not reverse the sign of 'x' values,
         * because this reversal is the job of a separated method (CoordinateSystems.swapAndScaleAxes)
         * which does is work by examining the axis directions. So we the values that we expect are:
         *
         *     expected  =  -W  =  E - 400
         */
    for (int i = 0; i < sources.length; i += 2) {
        expected[i] -= 400;
    }
    tolerance = Formulas.LINEAR_TOLERANCE;
    verifyTransform(sources, expected);
}
Also used : LambertConformalWest(org.apache.sis.internal.referencing.provider.LambertConformalWest) MathTransform(org.opengis.referencing.operation.MathTransform) Random(java.util.Random) LambertConformal1SP(org.apache.sis.internal.referencing.provider.LambertConformal1SP) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

Random (java.util.Random)1 LambertConformal1SP (org.apache.sis.internal.referencing.provider.LambertConformal1SP)1 LambertConformalWest (org.apache.sis.internal.referencing.provider.LambertConformalWest)1 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 Test (org.junit.Test)1 MathTransform (org.opengis.referencing.operation.MathTransform)1