Search in sources :

Example 66 with ParameterValueGroup

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

the class TensorValuesTest method testClone.

/**
 * Tests {@link TensorValues#clone()}.
 */
@Test
@DependsOnMethod("testParameter")
public void testClone() {
    final ParameterValueGroup group = createWKT1();
    group.parameter(NUM_ROW).setValue(2);
    group.parameter("elt_0_1").setValue(4);
    group.parameter("elt_1_0").setValue(2);
    /*
         * Creates a clone, modify some values, keep other values.
         */
    final ParameterValueGroup clone = group.clone();
    clone.parameter(NUM_ROW).setValue(4);
    clone.parameter("elt_0_1").setValue(3);
    /*
         * Verify that changes in cloned values did not affected
         * values in the original object.
         */
    assertEquals(2, group.parameter(NUM_ROW).intValue());
    assertEquals(4, clone.parameter(NUM_ROW).intValue());
    assertEquals(4, group.parameter("elt_0_1").intValue());
    assertEquals(3, clone.parameter("elt_0_1").intValue());
    assertEquals(2, group.parameter("elt_1_0").intValue());
    assertEquals(2, clone.parameter("elt_1_0").intValue());
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 67 with ParameterValueGroup

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

the class TensorValuesTest method testDescriptors.

/**
 * Tests {@link TensorValues#descriptors()} using WKT1 contentions.
 */
@Test
public void testDescriptors() {
    final Double N0 = 0.0;
    final Double N1 = 1.0;
    final Integer N3 = 3;
    final ParameterValueGroup group = createWKT1();
    group.parameter(NUM_ROW).setValue(1);
    group.parameter(NUM_COL).setValue(1);
    List<GeneralParameterDescriptor> descriptors = group.getDescriptor().descriptors();
    assertDescriptorEquals(NUM_ROW, N3, descriptors.get(0));
    assertDescriptorEquals(NUM_COL, N3, descriptors.get(1));
    assertDescriptorEquals("elt_0_0", N1, descriptors.get(2));
    assertEquals("size", 3, descriptors.size());
    group.parameter(NUM_ROW).setValue(2);
    group.parameter(NUM_COL).setValue(3);
    descriptors = group.getDescriptor().descriptors();
    assertDescriptorEquals(NUM_ROW, N3, descriptors.get(0));
    assertDescriptorEquals(NUM_COL, N3, descriptors.get(1));
    assertDescriptorEquals("elt_0_0", N1, descriptors.get(2));
    assertDescriptorEquals("elt_0_1", N0, descriptors.get(3));
    assertDescriptorEquals("elt_0_2", N0, descriptors.get(4));
    assertDescriptorEquals("elt_1_0", N0, descriptors.get(5));
    assertDescriptorEquals("elt_1_1", N1, descriptors.get(6));
    assertDescriptorEquals("elt_1_2", N0, descriptors.get(7));
    assertEquals("size", 8, descriptors.size());
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) Test(org.junit.Test)

Example 68 with ParameterValueGroup

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

the class CommonCRSTest method testUTM.

/**
 * Tests {@link CommonCRS#universal(double, double)} with Universal Transverse Mercator (UTM) projections.
 *
 * @since 0.7
 */
@Test
@DependsOnMethod("testGeographic")
public void testUTM() {
    final ProjectedCRS crs = CommonCRS.WGS72.universal(-45, -122);
    assertEquals("name", "WGS 72 / UTM zone 10S", crs.getName().getCode());
    final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues();
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.CENTRAL_MERIDIAN, -123, pg.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.SCALE_FACTOR, 0.9996, pg.parameter(Constants.SCALE_FACTOR).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_EASTING, 500000, pg.parameter(Constants.FALSE_EASTING).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 10000000, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.universal(-45, -122));
    assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.universal(+45, -122));
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 69 with ParameterValueGroup

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

the class CommonCRSTest method testUPS.

/**
 * Tests {@link CommonCRS#universal(double, double)} with Universal Polar Stereographic (UPS) projections.
 *
 * @since 0.8
 */
@Test
@DependsOnMethod("testGeographic")
public void testUPS() {
    final ProjectedCRS crs = CommonCRS.WGS72.universal(-85, -122);
    assertEquals("name", "WGS 72 / Universal Polar Stereographic South", crs.getName().getCode());
    final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues();
    assertEquals(Constants.LATITUDE_OF_ORIGIN, -90, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.CENTRAL_MERIDIAN, 0, pg.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.SCALE_FACTOR, 0.994, pg.parameter(Constants.SCALE_FACTOR).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_EASTING, 2000000, pg.parameter(Constants.FALSE_EASTING).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 2000000, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.universal(-85, -122));
    assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.universal(+85, -122));
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 70 with ParameterValueGroup

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

the class GeodeticObjectParserTest method testProjectedCRS.

/**
 * Tests the parsing of a projected CRS from a WKT 1 string.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
@DependsOnMethod("testGeographicCRS")
public void testProjectedCRS() throws ParseException {
    final ProjectedCRS crs = parse(ProjectedCRS.class, "PROJCS[“Mercator test”,\n" + "  GEOGCS[“WGS 84”,\n" + "    DATUM[“World Geodetic System 1984”,\n" + "      SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" + "      PRIMEM[“Greenwich”, 0.0],\n" + "    UNIT[“degree”, 0.017453292519943295],\n" + "    AXIS[“Longitude”, EAST],\n" + "    AXIS[“Latitude”, NORTH]],\n" + "  PROJECTION[“Mercator_1SP”],\n" + "  PARAMETER[“central_meridian”, -20.0],\n" + "  PARAMETER[“scale_factor”, 1.0],\n" + "  PARAMETER[“false_easting”, 500000.0],\n" + "  PARAMETER[“false_northing”, 0.0],\n" + "  UNIT[“metre”, 1.0],\n" + "  AXIS[“Easting”, EAST],\n" + "  AXIS[“Northing”, NORTH]]");
    assertNameAndIdentifierEqual("Mercator test", 0, crs);
    verifyProjectedCS(crs.getCoordinateSystem(), Units.METRE);
    verifyGeographicCRS(0, crs.getBaseCRS());
    final GeodeticDatum datum = crs.getDatum();
    assertNameAndIdentifierEqual("World Geodetic System 1984", 0, datum);
    assertNameAndIdentifierEqual("Greenwich", 0, datum.getPrimeMeridian());
    final Ellipsoid ellipsoid = datum.getEllipsoid();
    assertNameAndIdentifierEqual("WGS84", 0, ellipsoid);
    assertEquals("semiMajor", 6378137, ellipsoid.getSemiMajorAxis(), STRICT);
    assertEquals("inverseFlattening", 298.257223563, ellipsoid.getInverseFlattening(), STRICT);
    assertEquals("Mercator (variant A)", crs.getConversionFromBase().getMethod().getName().getCode());
    final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
    assertEquals("semi_major", 6378137.0, param.parameter("semi_major").doubleValue(Units.METRE), STRICT);
    assertEquals("semi_minor", 6356752.3, param.parameter("semi_minor").doubleValue(Units.METRE), 0.1);
    assertEquals("central_meridian", -20.0, param.parameter("central_meridian").doubleValue(Units.DEGREE), STRICT);
    assertEquals("scale_factor", 1.0, param.parameter("scale_factor").doubleValue(Units.UNITY), STRICT);
    assertEquals("false_easting", 500000.0, param.parameter("false_easting").doubleValue(Units.METRE), STRICT);
    assertEquals("false_northing", 0.0, param.parameter("false_northing").doubleValue(Units.METRE), STRICT);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) DefaultGeodeticDatum(org.apache.sis.referencing.datum.DefaultGeodeticDatum) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

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