Search in sources :

Example 6 with DependsOnMethod

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

the class CommonCRSTest method testSpherical.

/**
 * Tests the {@link CommonCRS#spherical()} method.
 */
@Test
@DependsOnMethod("testGeographic3D")
public void testSpherical() {
    final GeocentricCRS crs = CommonCRS.ETRS89.spherical();
    Validators.validate(crs);
    assertEquals("ETRS89", crs.getName().getCode());
    assertSame(CommonCRS.ETRS89.geographic().getDatum(), crs.getDatum());
    assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
    final CoordinateSystem cs = crs.getCoordinateSystem();
    final String name = cs.getName().getCode();
    assertTrue(name, name.startsWith("Spherical"));
    assertEquals("dimension", 3, cs.getDimension());
    assertAxisDirectionsEqual(name, cs, AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
    assertSame("Cached value", crs, CommonCRS.ETRS89.spherical());
}
Also used : CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 7 with DependsOnMethod

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

the class CommonCRSTest method testGeocentric.

/**
 * Tests the {@link CommonCRS#geocentric()} method.
 */
@Test
@DependsOnMethod("testGeographic3D")
public void testGeocentric() {
    final GeocentricCRS crs = CommonCRS.WGS72.geocentric();
    Validators.validate(crs);
    assertEquals("WGS 72", crs.getName().getCode());
    assertSame(CommonCRS.WGS72.geographic().getDatum(), crs.getDatum());
    assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
    final CoordinateSystem cs = crs.getCoordinateSystem();
    final String name = cs.getName().getCode();
    assertTrue(name, name.startsWith("Earth centred"));
    assertEquals("dimension", 3, cs.getDimension());
    assertAxisDirectionsEqual(name, cs, AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z);
    assertSame("Cached value", crs, CommonCRS.WGS72.geocentric());
}
Also used : CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 8 with DependsOnMethod

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

the class CommonCRSTest method testGeographic3D.

/**
 * Tests the {@link CommonCRS#geographic3D()} method.
 */
@Test
@DependsOnMethod("testGeographic")
public void testGeographic3D() {
    final GeographicCRS crs = CommonCRS.WGS72.geographic3D();
    Validators.validate(crs);
    assertEquals("WGS 72", crs.getName().getCode());
    assertSame(CommonCRS.WGS72.geographic().getDatum(), crs.getDatum());
    assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
    final EllipsoidalCS cs = crs.getCoordinateSystem();
    final String name = cs.getName().getCode();
    assertTrue(name, name.startsWith("Ellipsoidal 3D"));
    assertEquals("dimension", 3, cs.getDimension());
    assertAxisDirectionsEqual(name, cs, AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
    assertSame("Cached value", crs, CommonCRS.WGS72.geographic3D());
}
Also used : EllipsoidalCS(org.opengis.referencing.cs.EllipsoidalCS) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 9 with DependsOnMethod

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

the class CC_GeneralOperationParameterTest method testGroupMergeBecauseDifferentProperties.

/**
 * Tests case where the unmarshalled parameter group needs to be merged with the complete parameter group.
 * The reason for the group merge in this test is because the unmarshalled parameters have different remarks
 * or different obligation.
 *
 * @throws JAXBException if this method failed to create test data.
 */
@Test
@DependsOnMethod({ "testGroupSubstitution", "testParameterMerge" })
public void testGroupMergeBecauseDifferentProperties() throws JAXBException {
    final Map<String, String> properties = new HashMap<>(4);
    assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
    final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2, unmarshal("Parameter A", "Remarks A."), unmarshal("Parameter B", "Remarks B."), unmarshal("Parameter C", "Remarks C."));
    assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, "More details here."));
    final ParameterDescriptorGroup complete = new DefaultParameterDescriptorGroup(properties, 1, 2, create("Parameter A", "Remarks A.", true, 3), create("Parameter B", "Remarks B.", false, 4), create("Parameter C", "Different.", false, 5), create("Parameter D", "Remarks D.", false, 6));
    final ParameterDescriptorGroup merged = (ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
    assertNotSame(complete, provided);
    assertSame("name", complete.getName(), merged.getName());
    assertSame("remarks", complete.getRemarks(), merged.getRemarks());
    assertEquals("minimumOccurs", 1, merged.getMinimumOccurs());
    assertEquals("maximumOccurs", 2, merged.getMaximumOccurs());
    final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
    final Iterator<GeneralParameterDescriptor> itm = merged.descriptors().iterator();
    // Not same because different obligation.
    verifyParameter(itc.next(), itm.next(), false, "Remarks A.");
    // Same ParameterDescriptor instance.
    verifyParameter(itc.next(), itm.next(), true, "Remarks B.");
    // Not same because different remarks.
    verifyParameter(itc.next(), itm.next(), false, "Remarks C.");
    assertTrue("Missing descriptor.", itc.hasNext());
    assertFalse("Unexpected descriptor.", itm.hasNext());
}
Also used : DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) HashMap(java.util.HashMap) DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 10 with DependsOnMethod

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

the class CC_GeneralOperationParameterTest method testGroupMergeBecauseExtraParameter.

/**
 * Tests case where the unmarshalled parameter group needs to be merged with the complete parameter group.
 * The reason for the group merge in this test is because the unmarshalled parameters have a parameter not
 * present in the "complete" group.
 *
 * @throws JAXBException if this method failed to create test data.
 */
@Test
@DependsOnMethod("testGroupMergeBecauseDifferentProperties")
public void testGroupMergeBecauseExtraParameter() throws JAXBException {
    final Map<String, String> properties = new HashMap<>(4);
    assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
    final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2, unmarshal("Parameter A", "Remarks A."), unmarshal("Parameter B", "Remarks B."), unmarshal("Parameter C", "Remarks C."));
    assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, "More details here."));
    final ParameterDescriptorGroup complete = new DefaultParameterDescriptorGroup(properties, 1, 2, create("Parameter A", "Remarks A.", false, 3), create("Parameter C", "Remarks C.", false, 4));
    loggings.assertNoUnexpectedLog();
    final ParameterDescriptorGroup merged = (ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
    assertNotSame(complete, provided);
    assertSame("name", complete.getName(), merged.getName());
    assertSame("remarks", complete.getRemarks(), merged.getRemarks());
    assertEquals("minimumOccurs", 1, merged.getMinimumOccurs());
    assertEquals("maximumOccurs", 2, merged.getMaximumOccurs());
    loggings.assertNextLogContains("Parameter B", "Group");
    loggings.assertNoUnexpectedLog();
    final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
    final Iterator<GeneralParameterDescriptor> itm = merged.descriptors().iterator();
    verifyParameter(itc.next(), itm.next(), true, "Remarks A.");
    final GeneralParameterDescriptor extra = itm.next();
    assertEquals("name", "Parameter B", extra.getName().getCode());
    assertEquals("remark", "Remarks B.", extra.getRemarks().toString());
    verifyParameter(itc.next(), itm.next(), true, "Remarks C.");
    assertFalse("Unexpected descriptor.", itc.hasNext());
    assertFalse("Unexpected descriptor.", itm.hasNext());
}
Also used : DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) HashMap(java.util.HashMap) DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) 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