Search in sources :

Example 1 with ObliqueStereographic

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

the class InitializerTest method testRadiusOfConformalSphere.

/**
 * Tests the {@link Initializer#radiusOfConformalSphere(double)} method.
 * This test computes the Radius of Conformal Sphere using the values given
 * by the <a href="http://www.iogp.org/pubs/373-07-2.pdf">EPSG guide</a> for
 * the <cite>Amersfoort / RD New</cite> projection (a Stereographic one).
 */
@Test
public void testRadiusOfConformalSphere() {
    final OperationMethod op = new ObliqueStereographic();
    final ParameterValueGroup p = op.getParameters().createValue();
    /*
         * Following parameters are not given explicitely by EPSG definitions since they are
         * usually inferred from the datum.  However in the particular case of this test, we
         * need to provide them. The names used below are either OGC names or SIS extensions.
         */
    p.parameter("semi_major").setValue(6377397.155);
    p.parameter("inverse_flattening").setValue(299.15281);
    /*
         * Following parameters are reproduced verbatim from EPSG registry and EPSG guide.
         */
    p.parameter("Latitude of natural origin").setValue(52.156160556);
    p.parameter("Longitude of natural origin").setValue(5.387638889);
    p.parameter("Scale factor at natural origin").setValue(0.9999079);
    p.parameter("False easting").setValue(155000.00);
    p.parameter("False northing").setValue(463000.00);
    /*
         * The following lines are a typical way to create an Initializer instance.
         * The EnumMap tells to the Initializer constructor which parameters to look for.
         * We construct this map here for testing purpose, but users normally do not have
         * to do that since this map is provided by the ObliqueStereographic class itself.
         */
    final EnumMap<NormalizedProjection.ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(NormalizedProjection.ParameterRole.class);
    roles.put(NormalizedProjection.ParameterRole.CENTRAL_MERIDIAN, ObliqueStereographic.LONGITUDE_OF_ORIGIN);
    roles.put(NormalizedProjection.ParameterRole.SCALE_FACTOR, ObliqueStereographic.SCALE_FACTOR);
    roles.put(NormalizedProjection.ParameterRole.FALSE_EASTING, ObliqueStereographic.FALSE_EASTING);
    roles.put(NormalizedProjection.ParameterRole.FALSE_NORTHING, ObliqueStereographic.FALSE_NORTHING);
    final Initializer initializer = new Initializer(op, (Parameters) p, roles, (byte) 0);
    /*
         * The following lines give an example of how Apache SIS projection constructors
         * use the Initializer class.
         */
    final double φ0 = toRadians(initializer.getAndStore(ObliqueStereographic.LATITUDE_OF_ORIGIN));
    assertTrue(φ0 > 0);
    assertEquals("Conformal Sphere Radius", 6382644.571, 6377397.155 * initializer.radiusOfConformalSphere(sin(φ0)), Formulas.LINEAR_TOLERANCE);
}
Also used : ObliqueStereographic(org.apache.sis.internal.referencing.provider.ObliqueStereographic) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ParameterDescriptor(org.opengis.parameter.ParameterDescriptor) EnumMap(java.util.EnumMap) OperationMethod(org.opengis.referencing.operation.OperationMethod) Test(org.junit.Test)

Aggregations

EnumMap (java.util.EnumMap)1 ObliqueStereographic (org.apache.sis.internal.referencing.provider.ObliqueStereographic)1 Test (org.junit.Test)1 ParameterDescriptor (org.opengis.parameter.ParameterDescriptor)1 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)1 OperationMethod (org.opengis.referencing.operation.OperationMethod)1