use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class CommonAuthorityFactoryTest method testAuto42003.
/**
* Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42003"} code.
*
* @throws FactoryException if an error occurred while creating a CRS.
*/
@Test
@DependsOnMethod("testAuto42001")
@Ignore("Pending the port of Orthographic projection.")
public void testAuto42003() throws FactoryException {
final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42003,9001,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.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class InitializerTest method testRadiusOfConformalSphere.
/**
* Tests the {@link Initializer#radiusOfConformalSphere(double)} method.
* This test computes the Radius of Conformal Sphere using the values given
* by the <a href="http://www.iogp.org/pubs/373-07-2.pdf">EPSG guide</a> for
* the <cite>Amersfoort / RD New</cite> projection (a Stereographic one).
*/
@Test
public void testRadiusOfConformalSphere() {
final OperationMethod op = new 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.
*/
p.parameter("semi_major").setValue(6377397.155);
p.parameter("inverse_flattening").setValue(299.15281);
/*
* Following parameters are reproduced verbatim from EPSG registry and EPSG guide.
*/
p.parameter("Latitude of natural origin").setValue(52.156160556);
p.parameter("Longitude of natural origin").setValue(5.387638889);
p.parameter("Scale factor at natural origin").setValue(0.9999079);
p.parameter("False easting").setValue(155000.00);
p.parameter("False northing").setValue(463000.00);
/*
* The following lines are a typical way to create an Initializer instance.
* The EnumMap tells to the Initializer constructor which parameters to look for.
* We construct this map here for testing purpose, but users normally do not have
* to do that since this map is provided by the ObliqueStereographic class itself.
*/
final EnumMap<NormalizedProjection.ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(NormalizedProjection.ParameterRole.class);
roles.put(NormalizedProjection.ParameterRole.CENTRAL_MERIDIAN, ObliqueStereographic.LONGITUDE_OF_ORIGIN);
roles.put(NormalizedProjection.ParameterRole.SCALE_FACTOR, ObliqueStereographic.SCALE_FACTOR);
roles.put(NormalizedProjection.ParameterRole.FALSE_EASTING, ObliqueStereographic.FALSE_EASTING);
roles.put(NormalizedProjection.ParameterRole.FALSE_NORTHING, ObliqueStereographic.FALSE_NORTHING);
final Initializer initializer = new Initializer(op, (Parameters) p, roles, (byte) 0);
/*
* The following lines give an example of how Apache SIS projection constructors
* use the Initializer class.
*/
final double φ0 = toRadians(initializer.getAndStore(ObliqueStereographic.LATITUDE_OF_ORIGIN));
assertTrue(φ0 > 0);
assertEquals("Conformal Sphere Radius", 6382644.571, 6377397.155 * initializer.radiusOfConformalSphere(sin(φ0)), Formulas.LINEAR_TOLERANCE);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class ObliqueStereographicTest method testPolarStereographic.
/**
* Tests the delegation to {@link PolarStereographic} implementation when the latitude of origin is ±90°.
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
*/
@Test
public void testPolarStereographic() throws FactoryException, TransformException {
final OperationMethod op = new org.apache.sis.internal.referencing.provider.ObliqueStereographic();
final ParameterValueGroup p = op.getParameters().createValue();
p.parameter("semi_major").setValue(6378137);
p.parameter("inverse_flattening").setValue(298.2572236);
p.parameter("Latitude of natural origin").setValue(90);
p.parameter("Scale factor at natural origin").setValue(0.994);
p.parameter("False easting").setValue(2000000);
p.parameter("False northing").setValue(2000000);
transform = new ObliqueStereographic(op, (Parameters) p).createMapProjection(DefaultFactories.forBuildin(MathTransformFactory.class));
tolerance = 0.01;
verifyTransform(new double[] { 44, 73 }, new double[] { 3320416.75, 632668.43 });
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class DefaultMathTransformFactory method createCoordinateSystemChange.
/**
* Creates a math transform that represent a change of coordinate system. If exactly one argument is
* an {@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS ellipsoidal coordinate systems},
* then the {@code ellipsoid} argument is mandatory. In all other cases (including the case where both
* coordinate systems are ellipsoidal), the ellipsoid argument is ignored and can be {@code null}.
*
* <div class="note"><b>Design note:</b>
* this method does not accept separated ellipsoid arguments for {@code source} and {@code target} because
* this method should not be used for datum shifts. If the two given coordinate systems are ellipsoidal,
* then they are assumed to use the same ellipsoid. If different ellipsoids are desired, then a
* {@linkplain #createParameterizedTransform parameterized transform} like <cite>"Molodensky"</cite>,
* <cite>"Geocentric translations"</cite>, <cite>"Coordinate Frame Rotation"</cite> or
* <cite>"Position Vector transformation"</cite> should be used instead.</div>
*
* @param source the source coordinate system.
* @param target the target coordinate system.
* @param ellipsoid the ellipsoid of {@code EllipsoidalCS}, or {@code null} if none.
* @return a conversion from the given source to the given target coordinate system.
* @throws FactoryException if the conversion can not be created.
*
* @since 0.8
*/
public MathTransform createCoordinateSystemChange(final CoordinateSystem source, final CoordinateSystem target, final Ellipsoid ellipsoid) throws FactoryException {
ArgumentChecks.ensureNonNull("source", source);
ArgumentChecks.ensureNonNull("target", target);
if (ellipsoid != null) {
final boolean isEllipsoidalSource = (source instanceof EllipsoidalCS);
if (isEllipsoidalSource != (target instanceof EllipsoidalCS)) {
/*
* For now we support only conversion between EllipsoidalCS and CartesianCS.
* But future Apache SIS versions could add support for conversions between
* EllipsoidalCS and SphericalCS or other coordinate systems.
*/
if ((isEllipsoidalSource ? target : source) instanceof CartesianCS) {
final Context context = new Context();
final EllipsoidalCS cs;
final String operation;
if (isEllipsoidalSource) {
operation = GeographicToGeocentric.NAME;
context.setSource(cs = (EllipsoidalCS) source, ellipsoid);
context.setTarget(target);
} else {
operation = GeocentricToGeographic.NAME;
context.setSource(source);
context.setTarget(cs = (EllipsoidalCS) target, ellipsoid);
}
final ParameterValueGroup pg = getDefaultParameters(operation);
// Apache SIS specific parameter.
if (cs.getDimension() < 3)
pg.parameter("dim").setValue(2);
return createParameterizedTransform(pg, context);
}
}
}
return CoordinateSystemTransform.create(this, source, target);
// No need to use unique(…) here.
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class NormalizedProjection method getParameterValues.
/**
* Returns a copy of non-linear internal parameter values of this {@code NormalizedProjection}.
* The returned group contains at least the {@link #eccentricity} parameter value.
* Some subclasses add more non-linear parameters, but most of them do not because many parameters
* like the <cite>scale factor</cite> or the <cite>false easting/northing</cite> are handled by the
* {@linkplain ContextualParameters#getMatrix (de)normalization affine transforms} instead.
*
* <div class="note"><b>Note:</b>
* This method is mostly for {@linkplain org.apache.sis.io.wkt.Convention#INTERNAL debugging purposes}
* since the isolation of non-linear parameters in this class is highly implementation dependent.
* Most GIS applications will instead be interested in the {@linkplain #getContextualParameters()
* contextual parameters}.</div>
*
* @return a copy of the internal parameter values for this normalized projection.
*/
@Debug
@Override
public ParameterValueGroup getParameterValues() {
final ParameterValueGroup group = getParameterDescriptors().createValue();
group.parameter("eccentricity").setValue(eccentricity);
final String[] names = getInternalParameterNames();
final double[] values = getInternalParameterValues();
for (int i = 0; i < names.length; i++) {
group.parameter(names[i]).setValue(values[i]);
}
return group;
}
Aggregations