use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class MapProjectionParametersTest method testStandardParallel.
/**
* Tests the standard parallel dynamic parameter.
*/
@Test
public void testStandardParallel() {
final MapProjectionDescriptor descriptor = createDescriptor(2);
final ParameterValueGroup parameters = descriptor.createValue();
final ParameterValue<?> p = parameters.parameter(STANDARD_PARALLEL);
final ParameterValue<?> p1 = parameters.parameter(STANDARD_PARALLEL_1);
final ParameterValue<?> p2 = parameters.parameter(STANDARD_PARALLEL_2);
assertSame(p, parameters.parameter(STANDARD_PARALLEL));
assertSame(p1, parameters.parameter(STANDARD_PARALLEL_1));
assertSame(p2, parameters.parameter(STANDARD_PARALLEL_2));
assertNotSame(p1, p2);
assertNotSame(p1, p);
assertNotSame(p2, p);
/* Empty */
assertArrayEquals(new double[] {}, p.doubleValueList(), 0.0);
p1.setValue(40);
assertArrayEquals(new double[] { 40 }, p.doubleValueList(), 0.0);
p2.setValue(60);
assertArrayEquals(new double[] { 40, 60 }, p.doubleValueList(), 0.0);
p.setValue(new double[] { 30, 40 });
assertEquals(30, p1.doubleValue(), 0.0);
assertEquals(40, p2.doubleValue(), 0.0);
p.setValue(new double[] { 45 });
assertEquals(45, p1.doubleValue(), 0.0);
assertEquals(Double.NaN, p2.doubleValue(), 0.0);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class MapProjectionParametersTest method testInverseFlattening.
/**
* Tests the {@code "inverse_flattening"} dynamic parameter.
*/
@Test
public void testInverseFlattening() {
final MapProjectionDescriptor descriptor = createDescriptor(0);
final ParameterValueGroup parameters = descriptor.createValue();
// Clarke 1866
parameters.parameter(SEMI_MAJOR).setValue(6378206.4);
parameters.parameter(SEMI_MINOR).setValue(6356583.8);
assertEquals(294.97870, parameters.parameter(INVERSE_FLATTENING).doubleValue(), 0.00001);
assertEquals(6378206.4, parameters.parameter(SEMI_MAJOR).doubleValue(), 0.5);
assertEquals(6356583.8, parameters.parameter(SEMI_MINOR).doubleValue(), 0.5);
assertFalse("isIvfDefinitive", parameters.parameter(IS_IVF_DEFINITIVE).booleanValue());
// WGS84
parameters.parameter(SEMI_MAJOR).setValue(6378137.0);
parameters.parameter(INVERSE_FLATTENING).setValue(298.257223563);
assertEquals(298.257, parameters.parameter(INVERSE_FLATTENING).doubleValue(), 0.001);
assertEquals(6378137, parameters.parameter(SEMI_MAJOR).doubleValue(), 0.5);
assertEquals(6356752, parameters.parameter(SEMI_MINOR).doubleValue(), 0.5);
assertTrue("isIvfDefinitive", parameters.parameter(IS_IVF_DEFINITIVE).booleanValue());
// Clarke 1858 (approximative)
parameters.parameter(SEMI_MAJOR).setValue(6378350.9);
parameters.parameter(SEMI_MINOR).setValue(6356675.0);
assertEquals(294.26, parameters.parameter(INVERSE_FLATTENING).doubleValue(), 0.001);
assertFalse("isIvfDefinitive", parameters.parameter(IS_IVF_DEFINITIVE).booleanValue());
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class MapProjectionParametersTest method testSemiMinor.
/**
* Tests the inverse flattening dynamic parameter set after the semi-major axis length.
* This method tests actually the capability to compute the semi-minor axis length.
*/
@Test
public void testSemiMinor() {
final MapProjectionDescriptor descriptor = createDescriptor(0);
final ParameterValueGroup parameters = descriptor.createValue();
// WGS84
parameters.parameter(SEMI_MAJOR).setValue(6378137.000);
parameters.parameter(INVERSE_FLATTENING).setValue(298.257223563);
assertEquals(298.257, parameters.parameter(INVERSE_FLATTENING).doubleValue(), 0.001);
assertEquals(6378137, parameters.parameter(SEMI_MAJOR).doubleValue(), 0.5);
assertEquals(6356752, parameters.parameter(SEMI_MINOR).doubleValue(), 0.5);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class ParameterFormatTest method testMultiOccurrence.
/**
* Tests the formatting of a parameter value group with a cardinality
* invalid according ISO 19111, but allowed by Apache SIS implementation.
* ISO 19111 restricts {@link ParameterValue} cardinality to the [0 … 1] range,
* but SIS can handle arbitrary number of occurrences (2 in this test).
*/
@Test
@DependsOnMethod("testExtendedCardinality")
public void testMultiOccurrence() {
final ParameterValueGroup group = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue();
group.parameter("Mandatory 2").setValue(20);
final ParameterValue<?> value = group.parameter("Optional 4");
value.setValue(40);
/*
* Adding a second occurrence of the same parameter.
* Not straightforward because not allowed by ISO 19111.
*/
final ParameterValue<?> secondOccurrence = value.getDescriptor().createValue();
group.values().add(secondOccurrence);
secondOccurrence.setValue(50);
final ParameterFormat format = new ParameterFormat(null, null);
format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
final String text = format.format(group);
assertMultilinesEquals("Test group\n" + "┌─────────────┬─────────┬──────────────┬───────┐\n" + "│ Name │ Type │ Value domain │ Value │\n" + "├─────────────┼─────────┼──────────────┼───────┤\n" + "│ Mandatory 1 │ Integer │ │ 10 │\n" + "│ Mandatory 2 │ Integer │ │ 20 │\n" + "│ Optional 4 │ Integer │ │ 40 │\n" + "│ ″ │ ″ │ ″ │ 50 │\n" + "└─────────────┴─────────┴──────────────┴───────┘\n", text);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class ParameterFormatTest method createParameterValues.
/**
* Creates parameter values with some arbitrary values different than the default values.
* This method intentionally leaves {@code "central_meridian"} (a mandatory parameter) and
* {@code "false_easting"} (an optional parameter) undefined, in order to test whether the
* formatter fallback on default values.
*/
private static ParameterValueGroup createParameterValues() {
final ParameterValueGroup group = descriptor.createValue();
group.parameter("latitude_of_origin").setValue(20);
group.parameter("scale_factor").setValue(0.997);
group.parameter("false_northing").setValue(20, Units.KILOMETRE);
return group;
}
Aggregations