Search in sources :

Example 16 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class LinearTransformBuilder method toString.

/**
 * Returns a string representation of this builder for debugging purpose.
 *
 * @return a string representation of this builder.
 */
@Debug
@Override
public String toString() {
    final StringBuilder buffer = new StringBuilder(Classes.getShortClassName(this)).append('[');
    if (sources != null) {
        buffer.append(sources[0].length).append(" points");
    }
    buffer.append(']');
    if (transform != null) {
        final String lineSeparator = System.lineSeparator();
        buffer.append(':').append(lineSeparator);
        final TableAppender table = new TableAppender(buffer, " ");
        table.setMultiLinesCells(true);
        table.append(Matrices.toString(transform.getMatrix())).nextColumn();
        table.append(lineSeparator).append("  ").append(Vocabulary.format(Vocabulary.Keys.Correlation)).append(" =").nextColumn();
        table.append(Matrices.create(correlation.length, 1, correlation).toString());
        try {
            table.flush();
        } catch (IOException e) {
            // Should never happen since we wrote into a StringBuilder.
            throw new AssertionError(e);
        }
    }
    return buffer.toString();
}
Also used : TableAppender(org.apache.sis.io.TableAppender) IOException(java.io.IOException) Debug(org.apache.sis.util.Debug)

Example 17 with Debug

use of org.apache.sis.util.Debug 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;
}
Also used : ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) ParameterDescriptor(org.opengis.parameter.ParameterDescriptor) ParameterBuilder(org.apache.sis.parameter.ParameterBuilder) Debug(org.apache.sis.util.Debug)

Example 18 with Debug

use of org.apache.sis.util.Debug 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;
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Debug(org.apache.sis.util.Debug)

Example 19 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class EllipsoidToCentricTransform method getParameterDescriptors.

/**
 * Returns a description of the internal parameters of this {@code EllipsoidToCentricTransform} transform.
 * The returned group contains parameter descriptors for the number of dimensions and the eccentricity.
 *
 * @return a description of the internal parameters.
 */
@Debug
@Override
public ParameterDescriptorGroup getParameterDescriptors() {
    synchronized (EllipsoidToCentricTransform.class) {
        if (DESCRIPTOR == null) {
            final ParameterBuilder builder = new ParameterBuilder().setCodeSpace(Citations.SIS, Constants.SIS);
            final ParameterDescriptor<TargetType> target = builder.setRequired(true).addName("target").create(TargetType.class, TargetType.CARTESIAN);
            DESCRIPTOR = builder.addName("Ellipsoid (radians domain) to centric").createGroup(1, 1, ECCENTRICITY, target, DIMENSION);
        }
        return DESCRIPTOR;
    }
}
Also used : ParameterBuilder(org.apache.sis.parameter.ParameterBuilder) Debug(org.apache.sis.util.Debug)

Example 20 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class EllipsoidToCentricTransform method getParameterValues.

/**
 * Returns a copy of internal parameter values of this {@code EllipsoidToCentricTransform} transform.
 * The returned group contains parameter values for the number of dimensions and the eccentricity.
 *
 * <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 transform.
 */
@Debug
@Override
public ParameterValueGroup getParameterValues() {
    final Parameters pg = Parameters.castOrWrap(getParameterDescriptors().createValue());
    pg.getOrCreate(ECCENTRICITY).setValue(sqrt(eccentricitySquared));
    pg.parameter("target").setValue(getTargetType());
    pg.getOrCreate(DIMENSION).setValue(getSourceDimensions());
    return pg;
}
Also used : Parameters(org.apache.sis.parameter.Parameters) Debug(org.apache.sis.util.Debug)

Aggregations

Debug (org.apache.sis.util.Debug)20 IOException (java.io.IOException)4 InternationalString (org.opengis.util.InternationalString)4 TableAppender (org.apache.sis.io.TableAppender)3 ParameterBuilder (org.apache.sis.parameter.ParameterBuilder)3 TreeTable (org.apache.sis.util.collection.TreeTable)3 Map (java.util.Map)2 Parameters (org.apache.sis.parameter.Parameters)2 Console (java.io.Console)1 PrintWriter (java.io.PrintWriter)1 UncheckedIOException (java.io.UncheckedIOException)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 NilReferencingObject (org.apache.sis.internal.referencing.NilReferencingObject)1 FormattableObject (org.apache.sis.io.wkt.FormattableObject)1 ObjectConverter (org.apache.sis.util.ObjectConverter)1 DefaultTreeTable (org.apache.sis.util.collection.DefaultTreeTable)1 TreeTableFormat (org.apache.sis.util.collection.TreeTableFormat)1 ParameterDescriptor (org.opengis.parameter.ParameterDescriptor)1