Search in sources :

Example 81 with ParameterValueGroup

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

the class StoreTest method testSearchProviderParameter.

/**
 * Verifies that specifying a format effectively restricts the number of resources to be found.
 *
 * @throws URISyntaxException if the URL to test data can not be converted to a path of the file system.
 * @throws DataStoreException if an error occurred while reading the resources.
 * @throws IOException if an I/O error occurs.
 */
@Test
public void testSearchProviderParameter() throws URISyntaxException, DataStoreException, IOException {
    final Set<String> identifiers = new HashSet<>(Arrays.asList("Sample 1", "Sample 2", "Sample 3", "data4"));
    final ParameterValueGroup params = FolderStoreProvider.PARAMETERS.createValue();
    params.parameter("location").setValue(testDirectory());
    params.parameter("format").setValue("XML");
    try (Store store = (Store) FolderStoreProvider.INSTANCE.open(params)) {
        assertEquals("Expected one less data store.", 3, store.components().size());
        verifyContent(store, identifiers);
    }
    if (!identifiers.isEmpty()) {
        fail("Missing resources: " + identifiers);
    }
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 82 with ParameterValueGroup

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

the class EPSGFactoryTest method testProjectedNorthEast.

/**
 * Tests the "Beijing 1954 / 3-degree Gauss-Kruger CM 135E" projected CRS (EPSG:2442).
 * This projected CRS has (North, East) axis orientations instead of (East, North).
 *
 * @throws FactoryException if an error occurred while querying the factory.
 */
@Test
@DependsOnMethod("testProjected")
public void testProjectedNorthEast() throws FactoryException {
    final EPSGFactory factory = TestFactorySource.factory;
    assumeNotNull(factory);
    final ProjectedCRS crs = factory.createProjectedCRS(" EPSG : 2442 ");
    assertEpsgNameAndIdentifierEqual("Beijing 1954 / 3-degree Gauss-Kruger CM 135E", 2442, crs);
    assertAliasTipEquals("Beijing 1954 / 3GK 135E", crs);
    assertEpsgNameAndIdentifierEqual("Beijing 1954", 4214, crs.getBaseCRS());
    assertEpsgNameAndIdentifierEqual("Beijing 1954", 6214, crs.getDatum());
    assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, crs.getConversionFromBase().getMethod());
    assertEpsgNameAndIdentifierEqual("Gauss-Kruger CM 135E", 16323, crs.getConversionFromBase());
    assertAxisDirectionsEqual("EPSG::4530", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
    final ParameterValueGroup parameters = crs.getConversionFromBase().getParameterValues();
    assertEquals("Transverse Mercator", parameters.getDescriptor().getName().getCode());
    assertEquals("central_meridian", 135, parameters.parameter("central_meridian").doubleValue(), STRICT);
    assertEquals("latitude_of_origin", 0, parameters.parameter("latitude_of_origin").doubleValue(), STRICT);
    assertEquals("scale_factor", 1, parameters.parameter("scale_factor").doubleValue(), STRICT);
    assertEquals("false_easting", 500000, parameters.parameter("false_easting").doubleValue(), STRICT);
    assertEquals("false_northing", 0, parameters.parameter("false_northing").doubleValue(), STRICT);
    assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("2442"));
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 83 with ParameterValueGroup

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

the class CoordinateOperationFinderTest method testGeographic2D_to_3D.

/**
 * Tests the conversion from a two-dimensional geographic CRS to a three-dimensional geographic CRS.
 * Ordinate values of the vertical dimension should be set to zero.
 *
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testGeographic3D_to_2D")
public void testGeographic2D_to_3D() throws FactoryException, TransformException {
    final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic();
    final GeographicCRS targetCRS = CommonCRS.WGS84.geographic3D();
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    assertEquals("name", "Axis changes", operation.getName().getCode());
    assertInstanceOf("operation", Conversion.class, operation);
    final ParameterValueGroup parameters = ((SingleOperation) operation).getParameterValues();
    assertEquals("parameters.descriptor", "Geographic2D to 3D conversion", parameters.getDescriptor().getName().getCode());
    assertEquals("parameters.height", 0, parameters.parameter("height").doubleValue(), STRICT);
    transform = operation.getMathTransform();
    assertInstanceOf("transform", LinearTransform.class, transform);
    assertEquals("sourceDimensions", 2, transform.getSourceDimensions());
    assertEquals("targetDimensions", 3, transform.getTargetDimensions());
    Assert.assertMatrixEquals("transform.matrix", Matrices.create(4, 3, new double[] { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
    verifyTransform(new double[] { 30, 10, 20, 30 }, new double[] { 30, 10, 0, 20, 30, 0 });
    validate();
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) SingleOperation(org.opengis.referencing.operation.SingleOperation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 84 with ParameterValueGroup

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

the class CoordinateOperationFinderTest method testGeographicToProjected.

/**
 * Tests conversion from a geographic to a projected CRS without datum of axis changes.
 *
 * @throws ParseException if a CRS used in this test can not be parsed.
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testIdentityTransform")
public void testGeographicToProjected() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem sourceCRS = parse("$Sphere");
    final CoordinateReferenceSystem targetCRS = parse("ProjectedCRS[“TM”,\n" + "  $Sphere,\n" + "  Conversion[“TM”,\n" + "    Method[“Transverse Mercator”],\n" + "    Parameter[“Longitude of natural origin”, 170],\n" + "    Parameter[“Latitude of natural origin”, 50],\n" + "    Parameter[“Scale factor at natural origin”, 0.95]],\n" + "  CS[Cartesian, 2],\n" + "    Axis[“x”, EAST],\n" + "    Axis[“y”, NORTH],\n" + "    Unit[“US survey foot”, 0.304800609601219]]");
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    assertEquals("name", "TM", operation.getName().getCode());
    assertInstanceOf("operation", Projection.class, operation);
    final ParameterValueGroup param = ((SingleOperation) operation).getParameterValues();
    assertEquals("semi_major", 6370997, param.parameter("semi_major").doubleValue(), STRICT);
    assertEquals("semi_minor", 6370997, param.parameter("semi_minor").doubleValue(), STRICT);
    assertEquals("latitude_of_origin", 50, param.parameter("latitude_of_origin").doubleValue(), STRICT);
    assertEquals("central_meridian", 170, param.parameter("central_meridian").doubleValue(), STRICT);
    assertEquals("scale_factor", 0.95, param.parameter("scale_factor").doubleValue(), STRICT);
    assertEquals("false_easting", 0, param.parameter("false_easting").doubleValue(), STRICT);
    assertEquals("false_northing", 0, param.parameter("false_northing").doubleValue(), STRICT);
    transform = operation.getMathTransform();
    tolerance = ANGULAR_TOLERANCE;
    verifyTransform(new double[] { 170, 50 }, new double[] { 0, 0 });
    validate();
    transform = transform.inverse();
    tolerance = LINEAR_TOLERANCE;
    λDimension = new int[] { 0 };
    verifyTransform(new double[] { 0, 0 }, new double[] { 170, 50 });
    validate();
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) SingleOperation(org.opengis.referencing.operation.SingleOperation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 85 with ParameterValueGroup

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

the class DefaultConversionTest method verifyProperties.

/**
 * Asserts that at least some of the properties of the given {@code op} instance have the expected values
 * for an instance created by {@link #createLongitudeRotation(GeographicCRS, GeographicCRS, TemporalCRS)}.
 */
@SuppressWarnings("SuspiciousToArrayCall")
private static void verifyProperties(final DefaultConversion op, final boolean swapSourceAxes) {
    assertEquals("name", "Paris to Greenwich", op.getName().getCode());
    assertEquals("sourceCRS", "NTF (Paris)", op.getSourceCRS().getName().getCode());
    assertEquals("targetCRS", "Back to Greenwich", op.getTargetCRS().getName().getCode());
    assertEquals("method", "Longitude rotation", op.getMethod().getName().getCode());
    assertEquals("parameters", "Longitude rotation", op.getParameterDescriptors().getName().getCode());
    final ParameterValueGroup parameters = op.getParameterValues();
    final ParameterValue<?>[] values = parameters.values().toArray(new ParameterValue<?>[1]);
    assertEquals("parameters", "Longitude rotation", parameters.getDescriptor().getName().getCode());
    assertEquals("parameters[0]", "Longitude offset", values[0].getDescriptor().getName().getCode());
    assertEquals("parameters[0]", OFFSET, values[0].doubleValue(), STRICT);
    assertEquals(1, values.length);
    final Matrix3 expected = new Matrix3();
    expected.m02 = OFFSET;
    if (swapSourceAxes) {
        expected.m00 = expected.m11 = 0;
        expected.m01 = expected.m10 = 1;
    }
    assertMatrixEquals("Longitude rotation of a two-dimensional CRS", expected, MathTransforms.getMatrix(op.getMathTransform()), STRICT);
}
Also used : ParameterValue(org.opengis.parameter.ParameterValue) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3)

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