Package org.locationtech.proj4j.geoapi
Class ParameterAccessor
- java.lang.Object
-
- org.locationtech.proj4j.geoapi.Wrapper
-
- org.locationtech.proj4j.geoapi.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 thedouble
primitive type.
-
-
Field Summary
Fields Modifier and Type Field Description private static ParameterAccessor[]
ACCESSORS
Parameters that we can extract from aProjection
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 class org.locationtech.proj4j.geoapi.Wrapper
BIDIMENSIONAL, TRIDIMENSIONAL
-
-
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 org.locationtech.proj4j.geoapi.Wrapper
equals, getAlias, getAuthority, getCodeSpace, getDomainOfValidity, getIdentifiers, getName, getRemarks, getScope, getVersion, hashCode, toString, toWKT
-
-
-
-
Field Detail
-
ACCESSORS
private static final ParameterAccessor[] ACCESSORS
Parameters that we can extract from aProjection
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 namegetter
- the method to invoke for getting the parameter valuesetter
- the method to invoke for setting the parameter valueisScale
- whether this parameter is the scale factorangular
- 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 classWrapper
-
getCode
public java.lang.String getCode()
{@return the parameter name}.
-
getValueClass
public java.lang.Class<java.lang.Double> getValueClass()
{@return the class that describe the type of the parameter}.- Specified by:
getValueClass
in interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.opengis.parameter.ParameterDescriptor<java.lang.Double>
-
getMaximumValue
public java.lang.Comparable<java.lang.Double> getMaximumValue()
Unspecified.- Specified by:
getMaximumValue
in interfaceorg.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 PROJ4JProjection
instance.- Specified by:
getMinimumOccurs
in interfaceorg.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 interfaceorg.opengis.parameter.GeneralParameterDescriptor
-
getUnit
public javax.measure.Unit<?> getUnit()
{@return the unit of measurement}.- Specified by:
getUnit
in interfaceorg.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 fullProjection
object for each individual parameter value.- Specified by:
createValue
in interfaceorg.opengis.parameter.GeneralParameterDescriptor
- Specified by:
createValue
in interfaceorg.opengis.parameter.ParameterDescriptor<java.lang.Double>
- Returns:
- a new parameter value
-
-