use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class StandardDefinitionsTest method testCreateUPS.
/**
* Tests {@link StandardDefinitions#createUniversal(int, GeographicCRS, boolean, double, double, CartesianCS)}
* for a Universal Polar Stereographic (UPS) projection. This test cheats a little bit on the coordinate system
* by laziness; we are more interested in the projection parameters.
*
* @since 0.8
*/
@Test
@DependsOnMethod("testCreateGeographicCRS")
public void testCreateUPS() {
final ProjectedCRS crs = StandardDefinitions.createUniversal(5041, HardCodedCRS.WGS84, false, 90, -122, HardCodedCS.PROJECTED);
assertEquals("name", "WGS 84 / Universal Polar Stereographic North", 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);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class StandardDefinitionsTest method testCreateUTM.
/**
* Tests {@link StandardDefinitions#createUniversal(int, GeographicCRS, boolean, double, double, CartesianCS)}
* for a Universal Transverse Mercator (UTM) projection.
*
* @since 0.7
*/
@Test
@DependsOnMethod("testCreateGeographicCRS")
public void testCreateUTM() {
final ProjectedCRS crs = StandardDefinitions.createUniversal(32610, HardCodedCRS.WGS84, true, 15, -122, HardCodedCS.PROJECTED);
assertEquals("name", "WGS 84 / UTM zone 10N", 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, 0, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class DefaultDerivedCRSTest method testXML.
/**
* Tests (un)marshalling of a derived coordinate reference system.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*
* @since 0.7
*/
@Test
public void testXML() throws JAXBException {
final DefaultDerivedCRS crs = unmarshalFile(DefaultDerivedCRS.class, XML_FILE);
Validators.validate(crs);
assertEpsgNameAndIdentifierEqual("WGS 84", 4979, crs.getBaseCRS());
assertAxisDirectionsEqual("baseCRS", crs.getBaseCRS().getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
assertAxisDirectionsEqual("coordinateSystem", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH, AxisDirection.UP);
final Conversion conversion = crs.getConversionFromBase();
final ParameterValueGroup pg = conversion.getParameterValues();
assertEpsgNameAndIdentifierEqual("Geographic/topocentric conversions", 9837, conversion.getMethod());
assertEquals("Latitude", 55, pg.parameter("Latitude of topocentric origin").doubleValue(Units.DEGREE), STRICT);
assertEquals("Longitude", 5, pg.parameter("Longitude of topocentric origin").doubleValue(Units.DEGREE), STRICT);
assertEquals("Height", 0, pg.parameter("Ellipsoidal height of topocentric origin").doubleValue(Units.METRE), STRICT);
/*
* Test marshalling and compare with the original file.
*/
assertMarshalEqualsFile(XML_FILE, crs, "xmlns:*", "xsi:schemaLocation");
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class GeographicOffsetsTest method testCreateWithContext.
/**
* Tests {@code VerticalOffset.createMathTransform(…)} indirectly, through a call to the math transform factory
* with the source and target coordinate systems specified. The intent of this test is to verify that the change
* of axis direction is properly handled, given source CRS axis direction up and target CRS axis direction down.
*
* @throws FactoryException if an error occurred while creating the transform.
* @throws TransformException should never happen.
*/
@Test
public void testCreateWithContext() throws FactoryException, TransformException {
final DefaultMathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class, DefaultMathTransformFactory.class);
final ParameterValueGroup pv = factory.getDefaultParameters("Vertical Offset");
pv.parameter("Vertical Offset").setValue(15.55, Units.FOOT);
/*
* Now create the MathTransform. But at the difference of the above testVerticalOffset() method,
* we supply information about axis directions. The operation parameter shall have the same sign
* than in the EPSG database (which is positive), and the source and target ordinates shall have
* the same sign than in the EPSG example (positive too). However we do not test unit conversion
* in this method (EPSG sample point uses feet units), only axis direction.
*/
final DefaultMathTransformFactory.Context context = new DefaultMathTransformFactory.Context();
// Direction up, in metres.
context.setSource(HardCodedCS.GRAVITY_RELATED_HEIGHT);
// Direction down, in metres.
context.setTarget(HardCodedCS.DEPTH);
transform = factory.createParameterizedTransform(pv, context);
tolerance = Formulas.LINEAR_TOLERANCE;
final double[] source = new double[transform.getSourceDimensions()];
final double[] target = new double[transform.getTargetDimensions()];
// 2.55 metres up, same sign than in EPSG example (positive).
source[0] = 2.55;
// 7.18 feet down.
target[0] = 7.18 * 0.3048;
verifyTransform(source, target);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class GeographicOffsetsTest method testVerticalOffset.
/**
* Tests {@code VerticalOffset.createMathTransform(…)}.
* This test uses the sample point given in §2.4.2.1 of EPSG guide (April 2015)
* for the <cite>"KOC CD height to KOC WD depth (ft) (1)"</cite> transformation (EPSG:5453).
*
* <p><b>IMPORTANT:</b> since the source and target axis directions are opposite, the input coordinate
* need to be multiplied by -1 <strong>before</strong> the operation is applied. This order is required
* for consistency with the sign of <cite>"Vertical Offset"</cite> parameter value.</p>
*
* @throws FactoryException should never happen.
* @throws TransformException should never happen.
*/
@Test
public void testVerticalOffset() throws FactoryException, TransformException {
final VerticalOffset provider = new VerticalOffset();
final ParameterValueGroup pv = provider.getParameters().createValue();
pv.parameter("Vertical Offset").setValue(15.55, Units.FOOT);
transform = provider.createMathTransform(null, pv);
tolerance = Formulas.LINEAR_TOLERANCE;
final double[] source = new double[transform.getSourceDimensions()];
final double[] target = new double[transform.getTargetDimensions()];
// 2.55 metres up, sign reversed in order to match target axis direction.
source[0] = -2.55;
// 7.18 feet down.
target[0] = 7.18 * 0.3048;
verifyTransform(source, target);
}
Aggregations