Search in sources :

Example 6 with ParameterValueGroup

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

the class UnmodifiableParameterValueGroupTest method testCreate.

/**
 * Tests creation of an {@link UnmodifiableParameterValueGroup} and verify the values.
 */
@Test
public void testCreate() {
    ParameterValueGroup group = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue();
    group.parameter("Mandatory 1").setValue(5);
    group.parameter("Optional 3").setValue(8);
    group = UnmodifiableParameterValueGroup.create(group);
    assertEquals("values.size()", 3, group.values().size());
    assertEquals("values[0].name", "Mandatory 1", group.values().get(0).getDescriptor().getName().toString());
    assertEquals("values[1].name", "Mandatory 2", group.values().get(1).getDescriptor().getName().toString());
    assertEquals("values[2].name", "Optional 3", group.values().get(2).getDescriptor().getName().toString());
    assertEquals("values[0].value", 5, group.parameter("Mandatory 1").getValue());
    assertEquals("values[1].value", 10, group.parameter("Mandatory 2").getValue());
    assertEquals("values[2].value", 8, group.parameter("Optional 3").getValue());
    try {
        group.groups("dummy");
        fail("Shall not return non-existent groups.");
    } catch (ParameterNotFoundException e) {
        assertTrue(e.getMessage().contains("Test group"));
        assertTrue(e.getMessage().contains("dummy"));
    }
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ParameterNotFoundException(org.opengis.parameter.ParameterNotFoundException) Test(org.junit.Test)

Example 7 with ParameterValueGroup

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

the class UnmodifiableParameterValueGroupTest method ensureUnmodifiable.

/**
 * Ensures that {@link UnmodifiableParameterValueGroup} is unmodifiable.
 */
@Test
public void ensureUnmodifiable() {
    ParameterValueGroup group = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue();
    group.parameter("Mandatory 1").setValue(5);
    group.parameter("Optional 3").setValue(8);
    group = UnmodifiableParameterValueGroup.create(group);
    ParameterValue<?> param = group.parameter("Mandatory 1");
    try {
        param.setValue(5);
        fail("Shall not allow modification.");
    } catch (UnsupportedOperationException e) {
        assertTrue(e.getMessage().contains("ParameterValue"));
    }
    try {
        group.addGroup("dummy");
        fail("Shall not allow modification.");
    } catch (UnsupportedOperationException e) {
        assertTrue(e.getMessage().contains("ParameterValueGroup"));
    }
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Example 8 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup 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)

Example 9 with ParameterValueGroup

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

the class GeodeticObjectParserTest method testProjectedWithFeetUnits.

/**
 * Tests the parsing of a projected CRS with feet units.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
@DependsOnMethod("testProjectedCRS")
public void testProjectedWithFeetUnits() throws ParseException {
    final ProjectedCRS crs = parse(ProjectedCRS.class, "PROJCS[“TransverseMercator”,\n" + "  GEOGCS[“Sphere”,\n" + "    DATUM[“Sphere”,\n" + "      SPHEROID[“Sphere”, 6370997.0, 0.0],\n" + "      TOWGS84[0, 0, 0, 0, 0, 0, 0]],\n" + "      PRIMEM[“Greenwich”, 0.0],\n" + "    UNIT[“degree”, 0.017453292519943295],\n" + "    AXIS[“Longitude”, EAST],\n" + "    AXIS[“Latitude”, NORTH]],\n" + "  PROJECTION[“Transverse_Mercator”,\n" + "    AUTHORITY[“OGC”, “Transverse_Mercator”]],\n" + "  PARAMETER[“central_meridian”, 170.0],\n" + "  PARAMETER[“latitude_of_origin”, 50.0],\n" + "  PARAMETER[“scale_factor”, 0.95],\n" + "  PARAMETER[“false_easting”, 0.0],\n" + "  PARAMETER[“false_northing”, 0.0],\n" + "  UNIT[“US survey foot”, 0.304800609601219],\n" + "  AXIS[“E”, EAST],\n" + "  AXIS[“N”, NORTH]]");
    assertNameAndIdentifierEqual("TransverseMercator", 0, crs);
    assertNameAndIdentifierEqual("Sphere", 0, crs.getBaseCRS());
    assertNameAndIdentifierEqual("Sphere", 0, crs.getDatum());
    verifyProjectedCS(crs.getCoordinateSystem(), Units.US_SURVEY_FOOT);
    final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
    assertEquals("Transverse Mercator", crs.getConversionFromBase().getMethod().getName().getCode());
    assertEquals("semi_major", 6370997.0, param.parameter("semi_major").doubleValue(), 1E-5);
    assertEquals("semi_minor", 6370997.0, param.parameter("semi_minor").doubleValue(), 1E-5);
    assertEquals("latitude_of_origin", 50.0, param.parameter("latitude_of_origin").doubleValue(), 1E-8);
    assertEquals("central_meridian", 170.0, param.parameter("central_meridian").doubleValue(), 1E-8);
    assertEquals("scale_factor", 0.95, param.parameter("scale_factor").doubleValue(), 1E-8);
    assertEquals("false_easting", 0.0, param.parameter("false_easting").doubleValue(), 1E-8);
    assertEquals("false_northing", 0.0, param.parameter("false_northing").doubleValue(), 1E-8);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 10 with ParameterValueGroup

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

the class GeodeticObjectParserTest method testProjectedWithID.

/**
 * Tests the parsing of a projected CRS from a WKT 1 string with authority and Bursa-Wolf parameters.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
@DependsOnMethod("testProjectedCRS")
public void testProjectedWithID() throws ParseException {
    final ProjectedCRS crs = parse(ProjectedCRS.class, "PROJCS[“OSGB 1936 / British National Grid”,\n" + "  GEOGCS[“OSGB 1936”,\n" + "    DATUM[“OSGB_1936”,\n" + "      SPHEROID[“Airy 1830”, 6377563.396, 299.3249646, AUTHORITY[“EPSG”, “7001”]],\n" + "      TOWGS84[375.0, -111.0, 431.0, 0.0, 0.0, 0.0, 0.0],\n" + "      AUTHORITY[“EPSG”, “6277”]],\n" + "      PRIMEM[“Greenwich”,0.0, AUTHORITY[“EPSG”, “8901”]],\n" + "    UNIT[“DMSH”,0.0174532925199433],\n" + "    AXIS[“Lat”,NORTH],AXIS[“Long”,EAST], AUTHORITY[“EPSG”, “4277”]],\n" + "  PROJECTION[“Transverse_Mercator”],\n" + "  PARAMETER[“latitude_of_origin”, 49.0],\n" + "  PARAMETER[“central_meridian”, -2.0],\n" + "  PARAMETER[“scale_factor”, 0.999601272],\n" + "  PARAMETER[“false_easting”, 400000.0],\n" + "  PARAMETER[“false_northing”, -100000.0],\n" + "  UNIT[“metre”, 1.0, AUTHORITY[“EPSG”, “9001”]],\n" + "  AXIS[“E”,EAST],\n" + "  AXIS[“N”,NORTH],\n" + "  AUTHORITY[“EPSG”, “27700”]]");
    assertNameAndIdentifierEqual("OSGB 1936 / British National Grid", 27700, crs);
    assertNameAndIdentifierEqual("OSGB 1936", 4277, crs.getBaseCRS());
    assertNameAndIdentifierEqual("OSGB_1936", 6277, crs.getDatum());
    verifyProjectedCS(crs.getCoordinateSystem(), Units.METRE);
    final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
    assertEquals("Transverse Mercator", crs.getConversionFromBase().getMethod().getName().getCode());
    assertEquals("semi_major", 6377563.396, param.parameter("semi_major").doubleValue(), 1E-4);
    assertEquals("semi_minor", 6356256.909, param.parameter("semi_minor").doubleValue(), 1E-3);
    assertEquals("latitude_of_origin", 49.0, param.parameter("latitude_of_origin").doubleValue(), 1E-8);
    assertEquals("central_meridian", -2.0, param.parameter("central_meridian").doubleValue(), 1E-8);
    assertEquals("scale_factor", 0.9996, param.parameter("scale_factor").doubleValue(), 1E-5);
    assertEquals("false_easting", 400000.0, param.parameter("false_easting").doubleValue(), 1E-4);
    assertEquals("false_northing", -100000.0, param.parameter("false_northing").doubleValue(), 1E-4);
    final BursaWolfParameters[] bwp = ((DefaultGeodeticDatum) crs.getDatum()).getBursaWolfParameters();
    assertEquals("BursaWolfParameters", 1, bwp.length);
    assertArrayEquals("BursaWolfParameters", new double[] { 375, -111, 431 }, bwp[0].getValues(), STRICT);
}
Also used : DefaultGeodeticDatum(org.apache.sis.referencing.datum.DefaultGeodeticDatum) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) BursaWolfParameters(org.apache.sis.referencing.datum.BursaWolfParameters) 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