Search in sources :

Example 36 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class CommonAuthorityFactoryTest method testAuto42001.

/**
 * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42001"} code.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
public void testAuto42001() throws FactoryException {
    final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42001,-123,0");
    assertSame("With other coord.", crs, factory.createProjectedCRS("AUTO : 42001, -122, 10 "));
    assertSame("Omitting namespace.", crs, factory.createProjectedCRS(" 42001, -122 , 10 "));
    assertSame("With explicit unit.", crs, factory.createProjectedCRS("AUTO2 :  42001, 1, -122 , 10 "));
    assertSame("With explicit unit.", crs, factory.createProjectedCRS("AUTO1 :  42001, 9001, -122 , 10 "));
    assertSame("Legacy namespace.", crs, factory.createProjectedCRS("AUTO:42001,9001,-122,10"));
    assertSame("When the given parameters match exactly the UTM central meridian and latitude of origin," + " the CRS created by AUTO:42002 should be the same than the CRS created by AUTO:42001.", crs, factory.createProjectedCRS("AUTO2:42002,1,-123,0"));
    assertEpsgNameAndIdentifierEqual("WGS 84 / UTM zone 10N", 32610, crs);
    final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
    assertEquals(TransverseMercator.NAME, crs.getConversionFromBase().getMethod().getName().getCode());
    assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
    assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, p.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertEquals("axis[0].unit", Units.METRE, crs.getCoordinateSystem().getAxis(0).getUnit());
    try {
        factory.createObject("AUTO:42001");
        fail("Should not have accepted incomplete code.");
    } catch (NoSuchAuthorityCodeException e) {
        assertEquals("42001", e.getAuthorityCode());
    }
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Example 37 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class CommonAuthorityFactoryTest method testAuto42004.

/**
 * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42004"} code.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
@DependsOnMethod("testAuto42001")
public void testAuto42004() throws FactoryException {
    final ProjectedCRS crs = factory.createProjectedCRS("AUTO2:42004,1,10,45");
    final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
    assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
    assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 45, p.parameter(Constants.STANDARD_PARALLEL_1).doubleValue(), STRICT);
    assertInstanceOf("Opportunistic check: in the special case of Equirectangular projection, " + "SIS should have optimized the MathTransform as an affine transform.", LinearTransform.class, crs.getConversionFromBase().getMathTransform());
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 38 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class ObliqueStereographicTest method createNormalizedProjection.

/**
 * Creates a new instance of {@link ObliqueStereographic} for a sphere or an ellipsoid.
 * The new instance is stored in the inherited {@link #transform} field.
 *
 * @param  ellipse  {@code false} for the spherical case, or {@code true} for the ellipsoidal case.
 */
private void createNormalizedProjection(final boolean ellipse) {
    final OperationMethod op = new org.apache.sis.internal.referencing.provider.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.
         */
    if (!ellipse) {
        p.parameter("semi_major").setValue(R);
        p.parameter("semi_minor").setValue(R);
    } else {
        p.parameter("semi_major").setValue(a);
        p.parameter("inverse_flattening").setValue(ivf);
    }
    /*
         * Following parameters are reproduced verbatim from EPSG registry and EPSG guide.
         */
    p.parameter("Latitude of natural origin").setValue(φ0, Units.RADIAN);
    p.parameter("Longitude of natural origin").setValue(λ0, Units.RADIAN);
    p.parameter("Scale factor at natural origin").setValue(k0);
    p.parameter("False easting").setValue(FE, Units.METRE);
    p.parameter("False northing").setValue(FN, Units.METRE);
    transform = new ObliqueStereographic(op, (Parameters) p);
}
Also used : Parameters(org.apache.sis.parameter.Parameters) ContextualParameters(org.apache.sis.referencing.operation.transform.ContextualParameters) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) OperationMethod(org.opengis.referencing.operation.OperationMethod)

Example 39 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class ZonedGridSystemTest method testUTM.

/**
 * Tests converting a point using the <cite>Transverse Mercator Zoned Grid System</cite> projection.
 *
 * @throws FactoryException if an error occurred while creating the map projection.
 * @throws TransformException if an error occurred while transforming a coordinate.
 */
@Test
public void testUTM() throws FactoryException, TransformException {
    createProjection(true);
    /*
         * Verify parameters.
         */
    final ParameterValueGroup values = ((Parameterized) transform).getParameterValues();
    assertEquals(0.9996, values.parameter(Constants.SCALE_FACTOR).doubleValue(Units.UNITY), 0);
    assertEquals(500000, values.parameter(Constants.FALSE_EASTING).doubleValue(Units.METRE), 0);
    assertEquals(-180, values.parameter("Initial longitude").doubleValue(Units.DEGREE), 0);
    assertEquals(6, values.parameter("Zone width").doubleValue(Units.DEGREE), 0);
    /*
         * Tests projection of CN Tower coordinate, which is in UTM zone 17.
         */
    verifyTransform(new double[] { // 79°23′13.70″W
    -79 - (23 - 13.70 / 60) / 60, // 43°38′33.24″N
    43 + (38 + 33.24 / 60) / 60 }, new double[] { 17630698.19, 4833450.51 });
}
Also used : Parameterized(org.apache.sis.parameter.Parameterized) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Example 40 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class InterpolatedTransformTest method createRGF93.

/**
 * Creates the same transformation than <cite>"France geocentric interpolation"</cite> transform
 * (approximatively), but using shifts in geographic domain instead than in geocentric domain.
 *
 * @throws FactoryException if an error occurred while loading the grid.
 */
private void createRGF93() throws FactoryException {
    final URL file = NTv2Test.getResourceAsConvertibleURL(NTv2Test.TEST_FILE);
    final NTv2 provider = new NTv2();
    final ParameterValueGroup values = provider.getParameters().createValue();
    // Automatic conversion from URL to Path.
    values.parameter("Latitude and longitude difference file").setValue(file);
    transform = provider.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class), values);
    tolerance = Formulas.ANGULAR_TOLERANCE;
    validate();
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) NTv2(org.apache.sis.internal.referencing.provider.NTv2) URL(java.net.URL)

Aggregations

ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)98 Test (org.junit.Test)54 DependsOnMethod (org.apache.sis.test.DependsOnMethod)27 GeneralParameterValue (org.opengis.parameter.GeneralParameterValue)12 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)11 OperationMethod (org.opengis.referencing.operation.OperationMethod)11 ParameterValue (org.opengis.parameter.ParameterValue)8 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7 ParameterNotFoundException (org.opengis.parameter.ParameterNotFoundException)7 SingleOperation (org.opengis.referencing.operation.SingleOperation)6 FactoryException (org.opengis.util.FactoryException)6 DefaultGeodeticDatum (org.apache.sis.referencing.datum.DefaultGeodeticDatum)5 IdentifiedObject (org.opengis.referencing.IdentifiedObject)5 Matrix (org.opengis.referencing.operation.Matrix)5 ArrayList (java.util.ArrayList)4 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)4 ParameterDescriptorGroup (org.opengis.parameter.ParameterDescriptorGroup)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)4 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)4 URL (java.net.URL)3