Class ReferencingByIdentifiers.Coder
Object
Coder
- Direct Known Subclasses:
- GeohashReferenceSystem.Coder,- MilitaryGridReferenceSystem.Coder
- Enclosing class:
- ReferencingByIdentifiers
Conversions between direct positions and identifiers.
 Each 
Coder instance can read references at arbitrary precision,
 but formats at the specified approximate precision.
 The same Coder instance can be reused for reading or writing many identifiers.
 Immutability and thread safety
This class is not thread-safe. A new instance must be created for each thread, or synchronization must be applied by the caller.- Since:
- 1.3
Defined in the sis-referencing-by-identifiers module
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract AbstractLocationdecode(CharSequence identifier) Decodes the given identifier into a latitude and a longitude.abstract Stringencode(DirectPosition position) Encodes the given position into an identifier.encode(DirectPosition position, Quantity<?> precision) A combined method which sets the encoder precision to the given value, then formats the given position.abstract Quantity<?>getPrecision(DirectPosition position) Returns approximate precision of the identifiers formatted by this coder at the given location.abstract ReferencingByIdentifiersReturns the reference system for which this coder is reading or writing identifiers.abstract voidsetPrecision(Quantity<?> precision, DirectPosition position) Sets the desired precision of the identifiers formatted by this coder.
- 
Constructor Details- 
Coderprotected Coder()Creates a new instance.
 
- 
- 
Method Details- 
getReferenceSystemReturns the reference system for which this coder is reading or writing identifiers.- Returns:
- the enclosing reference system.
 
- 
getPrecisionReturns approximate precision of the identifiers formatted by this coder at the given location. The returned value is typically a length in linear unit (e.g. metres). Precisions in angular units should be converted to linear units at the specified location. If the location isnull, then this method should return a precision for the worst case scenario.- Parameters:
- position- where to evaluate the precision, or- nullfor the worst case scenario.
- Returns:
- approximate precision in metres of formatted identifiers.
 
- 
setPrecisionpublic abstract void setPrecision(Quantity<?> precision, DirectPosition position) throws IncommensurableException Sets the desired precision of the identifiers formatted by this coder. The given value is converted to coder-specific representation (e.g. number of digits). The value returned bygetPrecision(DirectPosition)may be different than the value specified to this method.- Parameters:
- precision- the desired precision.
- position- location where the specified precision is desired, or- nullfor the worst case scenario.
- Throws:
- IncommensurableException- if the given precision uses incompatible units of measurement.
 
- 
encodepublic String encode(DirectPosition position, Quantity<?> precision) throws IncommensurableException, TransformException A combined method which sets the encoder precision to the given value, then formats the given position. The default implementation is equivalent to the following code:
 Subclasses should override with more efficient implementation, for example by transforming the given position only once.setPrecision(precision, position); return encode(position); - Parameters:
- position- the coordinate to encode.
- precision- the desired precision.
- Returns:
- identifier of the given position.
- Throws:
- IncommensurableException- if the given precision uses incompatible units of measurement.
- TransformException- if an error occurred while transforming the given coordinate to an identifier.
 
- 
encodeEncodes the given position into an identifier. The given position must have a Coordinate Reference System (CRS) associated to it.- Parameters:
- position- the coordinate to encode.
- Returns:
- identifier of the given position.
- Throws:
- TransformException- if an error occurred while transforming the given coordinate to an identifier.
 
- 
decodeDecodes the given identifier into a latitude and a longitude. The axis order depends on the coordinate reference system of the enclosingReferencingByIdentifiers.Upcoming API change — generalization
 in a future SIS version, the type of returned element may be generalized to theorg.opengis.referencing.gazetteer.Locationinterface. This change is pending GeoAPI revision.- Parameters:
- identifier- identifier string to decode.
- Returns:
- a new geographic coordinate for the given identifier.
- Throws:
- TransformException- if an error occurred while parsing the given string.
 
 
-