use of org.opengis.parameter.ParameterDescriptor 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.ParameterDescriptor in project sis by apache.
the class NormalizedProjection method getParameterDescriptors.
/**
* Returns a description of the non-linear internal parameters of this {@code NormalizedProjection}.
* The returned group contains at least a descriptor for the {@link #eccentricity} parameter.
* Subclasses may add more parameters.
*
* <p>This method is for inspecting the parameter values of this non-linear kernel only,
* not for inspecting the {@linkplain #getContextualParameters() contextual parameters}.
* Inspecting the kernel parameter values is usually for debugging purpose only.</p>
*
* @return a description of the internal parameters.
*/
@Debug
@Override
public ParameterDescriptorGroup getParameterDescriptors() {
Class<?> type = getClass();
while (!Modifier.isPublic(type.getModifiers())) {
type = type.getSuperclass();
}
ParameterDescriptorGroup group;
synchronized (DESCRIPTORS) {
group = DESCRIPTORS.get(type);
if (group == null) {
final ParameterBuilder builder = new ParameterBuilder().setRequired(true);
if (type.getName().startsWith(Modules.CLASSNAME_PREFIX)) {
builder.setCodeSpace(Citations.SIS, Constants.SIS);
}
final String[] names = getInternalParameterNames();
final ParameterDescriptor<?>[] parameters = new ParameterDescriptor<?>[names.length + 1];
parameters[0] = MapProjection.ECCENTRICITY;
for (int i = 1; i < parameters.length; i++) {
parameters[i] = builder.addName(names[i - 1]).create(Double.class, null);
}
group = builder.addName(CharSequences.camelCaseToSentence(type.getSimpleName()) + " (radians domain)").createGroup(1, 1, parameters);
DESCRIPTORS.put(type, group);
}
}
return group;
}
Aggregations