use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class CommonAuthorityFactoryTest method testAuto42001.
/**
* Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42001"} code.
*
* @throws FactoryException if an error occurred while creating a CRS.
*/
@Test
public void testAuto42001() throws FactoryException {
final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42001,-123,0");
assertSame("With other coord.", crs, factory.createProjectedCRS("AUTO : 42001, -122, 10 "));
assertSame("Omitting namespace.", crs, factory.createProjectedCRS(" 42001, -122 , 10 "));
assertSame("With explicit unit.", crs, factory.createProjectedCRS("AUTO2 : 42001, 1, -122 , 10 "));
assertSame("With explicit unit.", crs, factory.createProjectedCRS("AUTO1 : 42001, 9001, -122 , 10 "));
assertSame("Legacy namespace.", crs, factory.createProjectedCRS("AUTO:42001,9001,-122,10"));
assertSame("When the given parameters match exactly the UTM central meridian and latitude of origin," + " the CRS created by AUTO:42002 should be the same than the CRS created by AUTO:42001.", crs, factory.createProjectedCRS("AUTO2:42002,1,-123,0"));
assertEpsgNameAndIdentifierEqual("WGS 84 / UTM zone 10N", 32610, crs);
final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
assertEquals(TransverseMercator.NAME, crs.getConversionFromBase().getMethod().getName().getCode());
assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, p.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
assertEquals("axis[0].unit", Units.METRE, crs.getCoordinateSystem().getAxis(0).getUnit());
try {
factory.createObject("AUTO:42001");
fail("Should not have accepted incomplete code.");
} catch (NoSuchAuthorityCodeException e) {
assertEquals("42001", e.getAuthorityCode());
}
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class CommonAuthorityFactoryTest method testAuto42004.
/**
* Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42004"} code.
*
* @throws FactoryException if an error occurred while creating a CRS.
*/
@Test
@DependsOnMethod("testAuto42001")
public void testAuto42004() throws FactoryException {
final ProjectedCRS crs = factory.createProjectedCRS("AUTO2:42004,1,10,45");
final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
assertEquals(Constants.LATITUDE_OF_ORIGIN, 45, p.parameter(Constants.STANDARD_PARALLEL_1).doubleValue(), STRICT);
assertInstanceOf("Opportunistic check: in the special case of Equirectangular projection, " + "SIS should have optimized the MathTransform as an affine transform.", LinearTransform.class, crs.getConversionFromBase().getMathTransform());
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class ObliqueStereographicTest method createNormalizedProjection.
/**
* Creates a new instance of {@link ObliqueStereographic} for a sphere or an ellipsoid.
* The new instance is stored in the inherited {@link #transform} field.
*
* @param ellipse {@code false} for the spherical case, or {@code true} for the ellipsoidal case.
*/
private void createNormalizedProjection(final boolean ellipse) {
final OperationMethod op = new org.apache.sis.internal.referencing.provider.ObliqueStereographic();
final ParameterValueGroup p = op.getParameters().createValue();
/*
* Following parameters are not given explicitely by EPSG definitions since they are
* usually inferred from the datum. However in the particular case of this test, we
* need to provide them. The names used below are either OGC names or SIS extensions.
*/
if (!ellipse) {
p.parameter("semi_major").setValue(R);
p.parameter("semi_minor").setValue(R);
} else {
p.parameter("semi_major").setValue(a);
p.parameter("inverse_flattening").setValue(ivf);
}
/*
* Following parameters are reproduced verbatim from EPSG registry and EPSG guide.
*/
p.parameter("Latitude of natural origin").setValue(φ0, Units.RADIAN);
p.parameter("Longitude of natural origin").setValue(λ0, Units.RADIAN);
p.parameter("Scale factor at natural origin").setValue(k0);
p.parameter("False easting").setValue(FE, Units.METRE);
p.parameter("False northing").setValue(FN, Units.METRE);
transform = new ObliqueStereographic(op, (Parameters) p);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class ZonedGridSystemTest method testUTM.
/**
* Tests converting a point using the <cite>Transverse Mercator Zoned Grid System</cite> projection.
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while transforming a coordinate.
*/
@Test
public void testUTM() throws FactoryException, TransformException {
createProjection(true);
/*
* Verify parameters.
*/
final ParameterValueGroup values = ((Parameterized) transform).getParameterValues();
assertEquals(0.9996, values.parameter(Constants.SCALE_FACTOR).doubleValue(Units.UNITY), 0);
assertEquals(500000, values.parameter(Constants.FALSE_EASTING).doubleValue(Units.METRE), 0);
assertEquals(-180, values.parameter("Initial longitude").doubleValue(Units.DEGREE), 0);
assertEquals(6, values.parameter("Zone width").doubleValue(Units.DEGREE), 0);
/*
* Tests projection of CN Tower coordinate, which is in UTM zone 17.
*/
verifyTransform(new double[] { // 79°23′13.70″W
-79 - (23 - 13.70 / 60) / 60, // 43°38′33.24″N
43 + (38 + 33.24 / 60) / 60 }, new double[] { 17630698.19, 4833450.51 });
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class InterpolatedTransformTest method createRGF93.
/**
* Creates the same transformation than <cite>"France geocentric interpolation"</cite> transform
* (approximatively), but using shifts in geographic domain instead than in geocentric domain.
*
* @throws FactoryException if an error occurred while loading the grid.
*/
private void createRGF93() throws FactoryException {
final URL file = NTv2Test.getResourceAsConvertibleURL(NTv2Test.TEST_FILE);
final NTv2 provider = new NTv2();
final ParameterValueGroup values = provider.getParameters().createValue();
// Automatic conversion from URL to Path.
values.parameter("Latitude and longitude difference file").setValue(file);
transform = provider.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class), values);
tolerance = Formulas.ANGULAR_TOLERANCE;
validate();
}
Aggregations