Search in sources :

Example 16 with DependsOnMethod

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

the class CodeTest method testWithVersion.

/**
 * Tests the {@link Code#Code(ReferenceIdentifier)} constructor with {@code "EPSG:8.3:4326"} identifier.
 * This test intentionally uses an identifier with the {@code IOGP} authority instead than EPSG
 * for the same reason than {@link #testSimple()}.
 */
@Test
@DependsOnMethod("testSimple")
public void testWithVersion() {
    final SimpleCitation IOGP = new SimpleCitation("IOGP");
    // See above javadoc.
    final ReferenceIdentifier id = new ImmutableIdentifier(IOGP, "EPSG", "4326", "8.2", null);
    final Code value = new Code(id);
    assertEquals("codeSpace", "EPSG:8.2", value.codeSpace);
    assertEquals("code", "4326", value.code);
    /*
         * Reverse operation. Note that the authority is lost since there is no room for that in a
         * <gml:identifier> element. Current implementation sets the authority to the code space.
         */
    final ReferenceIdentifier actual = value.getIdentifier();
    assertSame("authority", Citations.EPSG, actual.getAuthority());
    assertEquals("codeSpace", "EPSG", actual.getCodeSpace());
    assertEquals("version", "8.2", actual.getVersion());
    assertEquals("code", "4326", actual.getCode());
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) SimpleCitation(org.apache.sis.internal.simple.SimpleCitation) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 17 with DependsOnMethod

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

the class EllipsoidalHeightCombinerTest method testProjectedCRS.

/**
 * Tests {@link EllipsoidalHeightCombiner#createCompoundCRS EllipsoidalHeightCombiner.createCompoundCRS(…)}
 * with a projected CRS.
 *
 * @throws FactoryException if a CRS can not be created.
 */
@Test
@DependsOnMethod("testGeographicCRS")
public void testProjectedCRS() throws FactoryException {
    final EllipsoidalHeightCombiner services = create();
    final GeodeticObjectFactory factory = new GeodeticObjectFactory();
    final Map<String, String> properties = Collections.singletonMap(CoordinateReferenceSystem.NAME_KEY, "World Mercator (4D)");
    final ProjectedCRS horizontal = factory.createProjectedCRS(properties, HardCodedCRS.WGS84, HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED);
    final ProjectedCRS volumetric = factory.createProjectedCRS(properties, HardCodedCRS.WGS84_3D, HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED_3D);
    final VerticalCRS vertical = HardCodedCRS.ELLIPSOIDAL_HEIGHT;
    final TemporalCRS temporal = HardCodedCRS.TIME;
    final VerticalCRS geoidal = HardCodedCRS.GRAVITY_RELATED_HEIGHT;
    /*
         * createCompoundCRS(…) should not combine ProjectedCRS with non-ellipsoidal height.
         */
    CoordinateReferenceSystem compound = services.createCompoundCRS(properties, horizontal, geoidal, temporal);
    assertArrayEqualsIgnoreMetadata(new SingleCRS[] { horizontal, geoidal, temporal }, CRS.getSingleComponents(compound).toArray());
    /*
         * createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height.
         */
    compound = services.createCompoundCRS(properties, horizontal, vertical);
    assertArrayEqualsIgnoreMetadata(new SingleCRS[] { volumetric }, CRS.getSingleComponents(compound).toArray());
    /*
         * createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height and keep time.
         */
    compound = services.createCompoundCRS(properties, horizontal, vertical, temporal);
    assertArrayEqualsIgnoreMetadata(new SingleCRS[] { volumetric, temporal }, CRS.getSingleComponents(compound).toArray());
    /*
         * Non-standard feature: accept (VerticalCRS + ProjectedCRS) order.
         */
    compound = services.createCompoundCRS(properties, temporal, vertical, horizontal);
    final Object[] components = CRS.getSingleComponents(compound).toArray();
    assertEquals(2, components.length);
    assertEqualsIgnoreMetadata(temporal, components[0]);
    assertInstanceOf("Shall be a three-dimensional projected CRS.", ProjectedCRS.class, components[1]);
    assertAxisDirectionsEqual("Shall be a three-dimensional projected CRS.", ((CoordinateReferenceSystem) components[1]).getCoordinateSystem(), AxisDirection.UP, AxisDirection.EAST, AxisDirection.NORTH);
}
Also used : TemporalCRS(org.opengis.referencing.crs.TemporalCRS) ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeodeticObjectFactory(org.apache.sis.referencing.factory.GeodeticObjectFactory) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 18 with DependsOnMethod

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

the class DefinitionVerifierTest method testDifferentAxisOrder.

/**
 * Tests with a CRS having wrong axis order.
 *
 * @throws FactoryException if an error occurred while querying the authority factory.
 */
@Test
@DependsOnMethod("testNormalizedCRS")
public void testDifferentAxisOrder() throws FactoryException {
    final Map<String, Object> properties = new HashMap<>(4);
    properties.put(DefaultGeographicCRS.NAME_KEY, "WGS 84");
    properties.put(DefaultGeographicCRS.IDENTIFIERS_KEY, new NamedIdentifier(HardCodedCitations.EPSG, "4326"));
    DefaultGeographicCRS crs = HardCodedCRS.WGS84;
    crs = new DefaultGeographicCRS(properties, crs.getDatum(), crs.getCoordinateSystem());
    final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, false);
    assertNotNull("Should replace by normalized CRS", ver);
    assertNotSame("Should replace by normalized CRS", crs, ver.authoritative);
    assertSame("Should replace by normalized CRS", CommonCRS.WGS84.normalizedGeographic(), ver.authoritative);
    final LogRecord warning = ver.warning(true);
    assertNotNull("Should emit a warning.", warning);
    final String message = new SimpleFormatter().formatMessage(warning);
    assertTrue(message, message.contains("WGS 84"));
    assertTrue(message, message.contains("EPSG:4326"));
}
Also used : HashMap(java.util.HashMap) LogRecord(java.util.logging.LogRecord) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) SimpleFormatter(java.util.logging.SimpleFormatter) DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 19 with DependsOnMethod

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

the class DefinitionVerifierTest method testNormalizedCRS.

/**
 * Tests with a CRS which is conform to the authoritative definition.
 *
 * @throws FactoryException if an error occurred while querying the authority factory.
 */
@Test
@DependsOnMethod("testConformCRS")
public void testNormalizedCRS() throws FactoryException {
    final DefaultGeographicCRS crs = HardCodedCRS.WGS84;
    assertNull("No replacement without EPSG code.", DefinitionVerifier.withAuthority(crs, null, false));
    final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, true);
    assertNotNull("Should replace by normalized CRS", ver);
    assertNotSame("Should replace by normalized CRS", crs, ver.authoritative);
    assertSame("Should replace by normalized CRS", CommonCRS.WGS84.normalizedGeographic(), ver.authoritative);
    assertNull("Should be silent.", ver.warning(true));
}
Also used : DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 20 with DependsOnMethod

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

the class TransverseMercatorTest method testSetParameters.

/**
 * Tests {@link TransverseMercator.Zoner#setParameters(ParameterValueGroup, double, double)}
 * followed by {@link TransverseMercator.Zoner#zone(ParameterValueGroup)}.
 */
@Test
@DependsOnMethod({ "testZone", "testCentralMeridian" })
public void testSetParameters() {
    final ParameterValueGroup p = TransverseMercator.PARAMETERS.createValue();
    assertEquals("UTM zone 10N", TransverseMercator.Zoner.UTM.setParameters(p, 0, -122));
    assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertEquals("UTM.zone(parameters)", 10, TransverseMercator.Zoner.UTM.zone(p));
    assertEquals("Transverse Mercator", TransverseMercator.Zoner.ANY.setParameters(p, 0, -122));
    assertEquals(Constants.CENTRAL_MERIDIAN, -122, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertEquals("UTM.zone(parameters)", 0, TransverseMercator.Zoner.UTM.zone(p));
    assertEquals("UTM zone 10S", TransverseMercator.Zoner.ANY.setParameters(p, -0.0, -123));
    assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 10000000, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertEquals("UTM.zone(parameters)", -10, TransverseMercator.Zoner.UTM.zone(p));
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) 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