Search in sources :

Example 86 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class EPSGFactoryTest method testCompound.

/**
 * Tests the "NTF (Paris) + NGF IGN69 height" compound CRS (EPSG:7400).
 * This method tests also the domain of validity.
 *
 * @throws FactoryException if an error occurred while querying the factory.
 */
@Test
@DependsOnMethod({ "testGeographic2D", "testVertical" })
public void testCompound() throws FactoryException {
    final EPSGFactory factory = TestFactorySource.factory;
    assumeNotNull(factory);
    final CompoundCRS crs = factory.createCompoundCRS("EPSG:7400");
    assertEpsgNameAndIdentifierEqual("NTF (Paris) + NGF IGN69 height", 7400, crs);
    final List<CoordinateReferenceSystem> components = crs.getComponents();
    assertEquals("components.size()", 2, components.size());
    assertEpsgNameAndIdentifierEqual("NTF (Paris)", 4807, components.get(0));
    assertEpsgNameAndIdentifierEqual("NGF-IGN69 height", 5720, components.get(1));
    assertAxisDirectionsEqual("(no EPSG code)", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
    final GeographicBoundingBox bbox = CRS.getGeographicBoundingBox(crs);
    assertNotNull("No bounding box. Maybe an older EPSG database is used?", bbox);
    assertEquals("southBoundLatitude", 42.33, bbox.getSouthBoundLatitude(), STRICT);
    assertEquals("northBoundLatitude", 51.14, bbox.getNorthBoundLatitude(), STRICT);
    assertEquals("westBoundLongitude", -4.87, bbox.getWestBoundLongitude(), STRICT);
    assertEquals("eastBoundLongitude", 8.23, bbox.getEastBoundLongitude(), STRICT);
    assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("7400"));
}
Also used : GeographicBoundingBox(org.opengis.metadata.extent.GeographicBoundingBox) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 87 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class CoordinateOperationFinderTest method testSpatioTemporalToDerived.

/**
 * Tests conversion from spatio-temporal CRS to a derived CRS.
 *
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testProjected4D_to_2D")
public void testSpatioTemporalToDerived() throws FactoryException, TransformException {
    final Map<String, Object> properties = new HashMap<>();
    properties.put(DerivedCRS.NAME_KEY, "Display");
    properties.put("conversion.name", "Display to WGS84");
    final GeographicCRS WGS84 = CommonCRS.WGS84.normalizedGeographic();
    final CompoundCRS sourceCRS = compound("Test3D", WGS84, CommonCRS.Temporal.UNIX.crs());
    final DerivedCRS targetCRS = DefaultDerivedCRS.create(properties, WGS84, null, factory.getOperationMethod("Affine"), MathTransforms.linear(Matrices.create(3, 3, new double[] { 12, 0, 480, 0, -12, 790, 0, 0, 1 })), HardCodedCS.DISPLAY);
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    transform = operation.getMathTransform();
    assertInstanceOf("transform", LinearTransform.class, transform);
    assertEquals("sourceDimensions", 3, transform.getSourceDimensions());
    assertEquals("targetDimensions", 2, transform.getTargetDimensions());
    Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 4, new double[] { 12, 0, 0, 480, 0, -12, 0, 790, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
    validate();
}
Also used : HashMap(java.util.HashMap) CompoundCRS(org.opengis.referencing.crs.CompoundCRS) DefaultCompoundCRS(org.apache.sis.referencing.crs.DefaultCompoundCRS) DerivedCRS(org.opengis.referencing.crs.DerivedCRS) DefaultDerivedCRS(org.apache.sis.referencing.crs.DefaultDerivedCRS) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 88 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class CoordinateOperationFinderTest method testGeographic3D_to_2D.

/**
 * Tests the conversion from a three-dimensional geographic CRS to a two-dimensional geographic CRS.
 * The vertical dimension is simply dropped.
 *
 * @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 testGeographic3D_to_2D() throws FactoryException, TransformException {
    final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
    final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
    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", "Geographic3D to 2D conversion", parameters.getDescriptor().getName().getCode());
    assertTrue("parameters.isEmpty", parameters.values().isEmpty());
    transform = operation.getMathTransform();
    assertInstanceOf("transform", LinearTransform.class, transform);
    assertEquals("sourceDimensions", 3, transform.getSourceDimensions());
    assertEquals("targetDimensions", 2, transform.getTargetDimensions());
    Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 4, new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
    isInverseTransformSupported = false;
    verifyTransform(new double[] { 30, 10, 20, 20, 30, -10 }, new double[] { 30, 10, 20, 30 });
    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 89 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class CoordinateOperationFinderTest method testGeocentricTranslationInGeographic2D.

/**
 * Tests a transformation with a two-dimensional geographic source CRS.
 * This method verifies with both a two-dimensional and a three-dimensional target CRS.
 *
 * @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 testGeocentricTranslationInGeographic2D() throws ParseException, FactoryException, TransformException {
    /*
         * NAD27 (EPSG:4267) defined in WKT instead than relying on the CommonCRS.NAD27 constant in order to fix
         * the TOWGS84[…] parameter to values that we control. Note that TOWGS84[…] is not a legal WKT 2 element.
         * We could mix WKT 1 and WKT 2 elements (SIS allows that), but we nevertheless use WKT 1 for the whole
         * string as a matter of principle.
         */
    final GeographicCRS sourceCRS = (GeographicCRS) parse("GEOGCS[“NAD27”,\n" + "  DATUM[“North American Datum 1927”,\n" + "    SPHEROID[“Clarke 1866”, 6378206.4, 294.9786982138982],\n" + // EPSG:1173
    "    TOWGS84[-8, 160, 176]]," + "    PRIMEM[“Greenwich”, 0.0]," + "  UNIT[“degree”, 0.017453292519943295],\n" + "  AXIS[“Latitude (φ)”, NORTH],\n" + "  AXIS[“Longitude (λ)”, EAST],\n" + "  AUTHORITY[“EPSG”, “4267”]]");
    testGeocentricTranslationInGeographicDomain("Geocentric translations (geog2D domain)", sourceCRS, CommonCRS.WGS84.geographic());
    testGeocentricTranslationInGeographicDomain("Geocentric translations (geog3D domain)", sourceCRS, CommonCRS.WGS84.geographic3D());
}
Also used : GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 90 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class CoordinateOperationFinderTest method testPositionVectorTransformation.

/**
 * Tests a datum shift applied as a position vector transformation in geocentric domain.
 * This test does not use the the EPSG geodetic dataset.
 *
 * @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.
 *
 * @see DefaultCoordinateOperationFactoryTest#testPositionVectorTransformation()
 * @see <a href="https://issues.apache.org/jira/browse/SIS-364">SIS-364</a>
 *
 * @since 0.8
 */
@Test
@DependsOnMethod("testGeographicToProjected")
public void testPositionVectorTransformation() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic();
    final CoordinateReferenceSystem targetCRS = parse(AGD66());
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    transform = operation.getMathTransform();
    tolerance = LINEAR_TOLERANCE;
    λDimension = new int[] { 0 };
    verifyTransform(expectedAGD66(true), expectedAGD66(false));
    validate();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

DependsOnMethod (org.apache.sis.test.DependsOnMethod)298 Test (org.junit.Test)296 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)27 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)23 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)21 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)21 Rectangle (java.awt.Rectangle)19 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)19 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)18 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)15 Random (java.util.Random)11 Matrix (org.opengis.referencing.operation.Matrix)11 HashMap (java.util.HashMap)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)8 MathTransform (org.opengis.referencing.operation.MathTransform)8 DefaultFeatureType (org.apache.sis.feature.DefaultFeatureType)7 DefaultFeatureTypeTest (org.apache.sis.feature.DefaultFeatureTypeTest)7 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)7 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7