Class ParameterAccessor

  • All Implemented Interfaces:
    java.io.Serializable, org.opengis.metadata.Identifier, org.opengis.parameter.GeneralParameterDescriptor, org.opengis.parameter.ParameterDescriptor<java.lang.Double>, org.opengis.referencing.IdentifiedObject, org.opengis.referencing.ReferenceIdentifier

    final class ParameterAccessor
    extends Wrapper
    implements org.opengis.parameter.ParameterDescriptor<java.lang.Double>, java.io.Serializable
    Description of a PROJ4J parameter, together with method for getting and setting the value. This implementation is restricted to values of the double primitive type.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static ParameterAccessor[] ACCESSORS
      Parameters that we can extract from a Projection object.
      private boolean angular
      Whether the unit of measurement is angular (true) or linear (false).
      private java.util.function.ToDoubleFunction<Projection> getter
      The method to invoke for getting the parameter value.
      private boolean isScale
      Whether this parameter is the scale factor.
      private java.lang.String name
      The parameter name.
      private java.util.function.ObjDoubleConsumer<Projection> setter
      The method to invoke for setting the parameter value.
      • Fields inherited from interface org.opengis.referencing.IdentifiedObject

        ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
      • Fields inherited from interface org.opengis.metadata.Identifier

        AUTHORITY_KEY, CODE_KEY
      • Fields inherited from interface org.opengis.referencing.ReferenceIdentifier

        CODESPACE_KEY, VERSION_KEY
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ParameterAccessor​(java.lang.String name, java.util.function.ToDoubleFunction<Projection> getter, java.util.function.ObjDoubleConsumer<Projection> setter, boolean isScale, boolean angular)
      Creates a new parameter descriptor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.opengis.parameter.ParameterValue<java.lang.Double> createValue()
      Creates a new parameter value.
      private double defaultValue()
      {@return the default value as a primitive type}.
      (package private) static ParameterAccessor forName​(java.lang.String name)
      Returns the parameter descriptor of the given name.
      (package private) double get​(Projection proj)
      Gets the value of this parameter from the given projection.
      java.lang.String getCode()
      {@return the parameter name}.
      java.lang.Double getDefaultValue()
      {@return the default value as initialized in the PROJ4 projection class}.
      int getMaximumOccurs()
      {@return the maximum number of times that values for this parameter are required}.
      java.lang.Comparable<java.lang.Double> getMaximumValue()
      Unspecified.
      int getMinimumOccurs()
      {@return the minimum number of times that values for this parameter are required}.
      java.lang.Comparable<java.lang.Double> getMinimumValue()
      Unspecified.
      javax.measure.Unit<?> getUnit()
      {@return the unit of measurement}.
      java.util.Set<java.lang.Double> getValidValues()
      {@return null as this parameter is not restricted to a limited set of values}.
      java.lang.Class<java.lang.Double> getValueClass()
      {@return the class that describe the type of the parameter}.
      (package private) java.lang.Object implementation()
      {@return an identification of the parameter}.
      (package private) static ParameterAccessor[] nonDefault​(Projection proj)
      Returns all descriptors having a non-default values for the given PROJ4J projection.
      (package private) static void reset​(Projection proj)
      Resets all parameters to their default value.
      (package private) void set​(Projection proj, double value)
      Sets the value of this parameter in the given projection.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.opengis.referencing.IdentifiedObject

        getAlias, getIdentifiers, getName, getRemarks, toWKT
    • Field Detail

      • ACCESSORS

        private static final ParameterAccessor[] ACCESSORS
        Parameters that we can extract from a Projection object. Does not include the ellipsoid axis length of flattening factors.
      • name

        private final java.lang.String name
        The parameter name. Should be OGC names if possible. This name may not be correct in all cases, because some names depend on the projection method. For example, "latitude of origin" may be "latitude of center" in some projections.
      • getter

        private final java.util.function.ToDoubleFunction<Projection> getter
        The method to invoke for getting the parameter value.
      • setter

        private final java.util.function.ObjDoubleConsumer<Projection> setter
        The method to invoke for setting the parameter value.
      • isScale

        private final boolean isScale
        Whether this parameter is the scale factor. That parameter has a different default value.
      • angular

        private final boolean angular
        Whether the unit of measurement is angular (true) or linear (false).
    • Constructor Detail

      • ParameterAccessor

        private ParameterAccessor​(java.lang.String name,
                                  java.util.function.ToDoubleFunction<Projection> getter,
                                  java.util.function.ObjDoubleConsumer<Projection> setter,
                                  boolean isScale,
                                  boolean angular)
        Creates a new parameter descriptor.
        Parameters:
        name - the parameter name
        getter - the method to invoke for getting the parameter value
        setter - the method to invoke for setting the parameter value
        isScale - whether this parameter is the scale factor
        angular - whether the unit of measurement is angular (true) or linear (false)
    • Method Detail

      • forName

        static ParameterAccessor forName​(java.lang.String name)
        Returns the parameter descriptor of the given name.
        Parameters:
        name - name of the desired parameter
        Returns:
        parameter descriptor for the given name
        Throws:
        org.opengis.parameter.ParameterNotFoundException - if the given name is unknown
      • nonDefault

        static ParameterAccessor[] nonDefault​(Projection proj)
        Returns all descriptors having a non-default values for the given PROJ4J projection. We do not have a formal list of parameters that are valid for each projection. Therefore, checking for non-default values is workaround.
      • reset

        static void reset​(Projection proj)
        Resets all parameters to their default value.
      • implementation

        java.lang.Object implementation()
        {@return an identification of the parameter}.
        Specified by:
        implementation in class Wrapper
      • getCode

        public java.lang.String getCode()
        {@return the parameter name}.
        Specified by:
        getCode in interface org.opengis.metadata.Identifier
        Specified by:
        getCode in class Wrapper
      • getValueClass

        public java.lang.Class<java.lang.Double> getValueClass()
        {@return the class that describe the type of the parameter}.
        Specified by:
        getValueClass in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
      • getValidValues

        public java.util.Set<java.lang.Double> getValidValues()
        {@return null as this parameter is not restricted to a limited set of values}.
        Specified by:
        getValidValues in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
      • getDefaultValue

        public java.lang.Double getDefaultValue()
        {@return the default value as initialized in the PROJ4 projection class}.
        Specified by:
        getDefaultValue in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
      • defaultValue

        private double defaultValue()
        {@return the default value as a primitive type}.
      • getMinimumValue

        public java.lang.Comparable<java.lang.Double> getMinimumValue()
        Unspecified.
        Specified by:
        getMinimumValue in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
      • getMaximumValue

        public java.lang.Comparable<java.lang.Double> getMaximumValue()
        Unspecified.
        Specified by:
        getMaximumValue in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
      • getMinimumOccurs

        public int getMinimumOccurs()
        {@return the minimum number of times that values for this parameter are required}. The value should be 1 for mandatory parameters and 0 for optional parameters. We consider all parameters as optional, because we don't know for sure which parameters are used by a particular PROJ4J Projection instance.
        Specified by:
        getMinimumOccurs in interface org.opengis.parameter.GeneralParameterDescriptor
      • getMaximumOccurs

        public int getMaximumOccurs()
        {@return the maximum number of times that values for this parameter are required}. Values greater than 1 should happen only with parameter groups, which are not used in this implementation.
        Specified by:
        getMaximumOccurs in interface org.opengis.parameter.GeneralParameterDescriptor
      • getUnit

        public javax.measure.Unit<?> getUnit()
        {@return the unit of measurement}.
        Specified by:
        getUnit in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
      • get

        final double get​(Projection proj)
        Gets the value of this parameter from the given projection.
      • set

        final void set​(Projection proj,
                       double value)
        Sets the value of this parameter in the given projection.
      • createValue

        public org.opengis.parameter.ParameterValue<java.lang.Double> createValue()
        Creates a new parameter value. Note that this method is inefficient as it creates a full Projection object for each individual parameter value.
        Specified by:
        createValue in interface org.opengis.parameter.GeneralParameterDescriptor
        Specified by:
        createValue in interface org.opengis.parameter.ParameterDescriptor<java.lang.Double>
        Returns:
        a new parameter value