Class ParameterAccessor

java.lang.Object
org.locationtech.proj4j.geoapi.Wrapper
org.locationtech.proj4j.geoapi.ParameterAccessor
All Implemented Interfaces:
Serializable, org.opengis.metadata.Identifier, org.opengis.parameter.GeneralParameterDescriptor, org.opengis.parameter.ParameterDescriptor<Double>, org.opengis.referencing.IdentifiedObject, org.opengis.referencing.ReferenceIdentifier

final class ParameterAccessor extends Wrapper implements org.opengis.parameter.ParameterDescriptor<Double>, 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 Details

    • 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 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 ToDoubleFunction<Projection> getter
      The method to invoke for getting the parameter value.
    • setter

      private final 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 Details

    • ParameterAccessor

      private ParameterAccessor(String name, ToDoubleFunction<Projection> getter, 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 Details

    • forName

      static ParameterAccessor forName(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

      Object implementation()
      Returns an identification of the parameter..
      Specified by:
      implementation in class Wrapper
      Returns:
      an identification of the parameter
    • getCode

      public String getCode()
      Returns the parameter name..
      Specified by:
      getCode in interface org.opengis.metadata.Identifier
      Specified by:
      getCode in class Wrapper
      Returns:
      the parameter name
    • getValueClass

      public Class<Double> getValueClass()
      Returns the class that describe the type of the parameter..
      Specified by:
      getValueClass in interface org.opengis.parameter.ParameterDescriptor<Double>
      Returns:
      the class that describe the type of the parameter
    • getValidValues

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

      public Double getDefaultValue()
      Returns the default value as initialized in the PROJ4 projection class..
      Specified by:
      getDefaultValue in interface org.opengis.parameter.ParameterDescriptor<Double>
      Returns:
      the default value as initialized in the PROJ4 projection class
    • defaultValue

      private double defaultValue()
      Returns the default value as a primitive type..
      Returns:
      the default value as a primitive type
    • getMinimumValue

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

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

      public int getMinimumOccurs()
      Returns 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
      Returns:
      the minimum number of times that values for this parameter are required
    • getMaximumOccurs

      public int getMaximumOccurs()
      Returns 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
      Returns:
      the maximum number of times that values for this parameter are required
    • getUnit

      public javax.measure.Unit<?> getUnit()
      Returns the unit of measurement..
      Specified by:
      getUnit in interface org.opengis.parameter.ParameterDescriptor<Double>
      Returns:
      the unit of measurement
    • 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<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<Double>
      Returns:
      a new parameter value