Search in sources :

Example 1 with LambertConformal1SP

use of org.apache.sis.internal.referencing.provider.LambertConformal1SP 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)

Example 2 with LambertConformal1SP

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

the class LambertConicConformalTest method compareEllipticalWithSpherical.

/**
 * Verifies the consistency of elliptical formulas with the spherical formulas.
 * This test compares the results of elliptical formulas with the spherical ones
 * for some random points.
 *
 * @throws FactoryException if an error occurred while creating the map projection.
 * @throws TransformException if an error occurred while projecting a coordinate.
 */
@Test
@DependsOnMethod("testSphericalCase")
public void compareEllipticalWithSpherical() throws FactoryException, TransformException {
    createCompleteProjection(new LambertConformal1SP(), // Semi-major axis length
    6371007, // Semi-minor axis length
    6371007, // 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);
    tolerance = Formulas.LINEAR_TOLERANCE;
    compareEllipticalWithSpherical(CoordinateDomain.GEOGRAPHIC_SAFE, 0);
}
Also used : LambertConformal1SP(org.apache.sis.internal.referencing.provider.LambertConformal1SP) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with LambertConformal1SP

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

the class LambertConicConformalTest method createNormalizedProjection.

/**
 * Creates a new instance of {@link LambertConicConformal}. See the class javadoc for an explanation
 * about why we ask only for the latitude of origin and not the standard parallels.
 *
 * @param  ellipse           {@code false} for a sphere, or {@code true} for WGS84 ellipsoid.
 * @param  latitudeOfOrigin  the latitude of origin, in decimal degrees.
 */
private void createNormalizedProjection(final boolean ellipse, final double latitudeOfOrigin) {
    final LambertConformal1SP method = new LambertConformal1SP();
    final Parameters parameters = parameters(method, ellipse);
    parameters.getOrCreate(LambertConformal1SP.LATITUDE_OF_ORIGIN).setValue(latitudeOfOrigin);
    transform = new LambertConicConformal(method, parameters);
    if (!ellipse) {
        transform = new LambertConicConformal.Spherical((LambertConicConformal) transform);
    }
    tolerance = NORMALIZED_TOLERANCE;
    validate();
}
Also used : Parameters(org.apache.sis.parameter.Parameters) LambertConformal1SP(org.apache.sis.internal.referencing.provider.LambertConformal1SP)

Aggregations

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