Package org.n52.svalbard.encode
Class UVFEncoder
- java.lang.Object
-
- org.n52.svalbard.encode.UVFEncoder
-
- All Implemented Interfaces:
Component<EncoderKey>,Keyed<EncoderKey>,ConformanceClass,Encoder<BinaryAttachmentResponse,Object>,ObservationEncoder<BinaryAttachmentResponse,Object>
@Configurable public class UVFEncoder extends Object implements ObservationEncoder<BinaryAttachmentResponse,Object>
The UVFEncoder implements the so called Universal Variable Format. The definitions found on the internet are the following: It is used for exchanging timeseries and looks like the following:0: $sb Index-Einheit: 1: $ib Funktion-Interpretation: Summenlinie 2: $sb Mess-Groesse: Niederschlag 3: $sb Mess-Einheit: mm 4: $sb Mess-Stellennummer: 5242 5: *Z 6: Niederschlag: mm 1900 2000 7: 5242 1231240 1413414 52.52 8: 73110107301002100636Zeit 9: 7311010730 0 10: 7311050224 0 11: 7311050240 .30333331 12: 7311050255 .5 13: 7311050414 .5 14: 7311050415 -777 15: 7311050419 -777 16: 7311050420 .80000001
The Lines 0 to 8 specify the header of the dataset. Hereby, the lines 0 to 4 provide optional metadata. The lines 5 to 8 are mandatory and are referenced in the specification by "Zeile 1,2,3,4". Line 14 and 15 show the handling of gaps or no data values. They are encoded with-777. Gaps are defined by two values: one for the start and one for the end of the gap. The following assumptions/constraints are implemented:- Only ONE timeseries will be encoded. Hence, the
UVFRequestModifierensures, that each request for the UVF contains ONE observed property, ONE feature of interest, and ONE procedure. - Only observations of type Measurement and Count are supported.
- The encoder does not check for gaps and encodes only start and end. This MUST be done before inserting the data in the SOS database.
- Identifiers are shortened via
String.substring(int, int)to the length ofUVFConstants.MAX_IDENTIFIER_LENGTH(15) starting from the end of the given identifier. - Values (e.g. measurements and coordinates) are shortened via
String.substring(int, int)to the length ofUVFConstants.MAX_VALUE_LENGTH(10) starting form the beginning of the String representation of the value. No rounding is performed. - The UVF requires that all coordinates are in Gauß Krüger, hence a
coordinate transformation is performed before the response is encoded. This
requires that the EPSG code of the best matching GK band is given. When not
present in the request, a default value is used. This value can be specified
using the admin WebUI of the SOS. Currently the following EPSG codes are
allowed (see
UVFConstants.ALLOWED_CRS):- 31466
- 31467
- 31468
- 31469
-
-
Constructor Summary
Constructors Constructor Description UVFEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BinaryAttachmentResponseencode(Object objectToEncode)Encodes the specified object.BinaryAttachmentResponseencode(Object objectToEncode, EncodingContext additionalValues)Encodes the specified object with the specified EncodingContext .MediaTypegetContentType()Set<EncoderKey>getKeys()Map<String,Set<SupportedType>>getSupportedResponseFormatObservationTypes()Set<String>getSupportedResponseFormats(String service, String version)Get the supported response formats for this ObservationEncoder and the specified service and version.Set<SupportedType>getSupportedTypes()Get theSupportedTypebooleanisObservationAndMeasurmentV20Type()Indicator whether the ObservationEncoder of type or subtype Observation & Measurement 2.0voidsetLineEnding(String lineEndingParameter)voidsetTimeZone(String timeZone)booleanshouldObservationsWithSameXBeMerged()Indicator whether the single observations with the same procedure, observableProperty and featureOfInterest should be merged to one observation.booleansupportsResultStreamingForMergedValues()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.n52.svalbard.ConformanceClass
getConformanceClasses
-
Methods inherited from interface org.n52.svalbard.encode.ObservationEncoder
getProcedureEncodingNamspace, getSupportedResponseFormats
-
-
-
-
Method Detail
-
getKeys
public Set<EncoderKey> getKeys()
- Specified by:
getKeysin interfaceKeyed<EncoderKey>
-
encode
public BinaryAttachmentResponse encode(Object objectToEncode) throws EncodingException
Description copied from interface:EncoderEncodes the specified object.- Specified by:
encodein interfaceEncoder<BinaryAttachmentResponse,Object>- Parameters:
objectToEncode- the object to encode- Returns:
- the encoded object
- Throws:
EncodingException- if an error occurs
-
encode
public BinaryAttachmentResponse encode(Object objectToEncode, EncodingContext additionalValues) throws EncodingException
Description copied from interface:EncoderEncodes the specified object with the specified EncodingContext .- Specified by:
encodein interfaceEncoder<BinaryAttachmentResponse,Object>- Parameters:
objectToEncode- the object to encodeadditionalValues- the helper values- Returns:
- the encoded object
- Throws:
EncodingException- if an error occurs
-
setTimeZone
@Setting(value="uvf.timeZone", required=false) public void setTimeZone(String timeZone)
-
setLineEnding
@Setting(value="uvf.lineEnding", required=false) public void setLineEnding(String lineEndingParameter)
-
getSupportedTypes
public Set<SupportedType> getSupportedTypes()
Description copied from interface:EncoderGet theSupportedType- Specified by:
getSupportedTypesin interfaceEncoder<BinaryAttachmentResponse,Object>- Returns:
- the supported key types
-
getContentType
public MediaType getContentType()
- Specified by:
getContentTypein interfaceEncoder<BinaryAttachmentResponse,Object>- Returns:
- the content type of the encoded response.
-
isObservationAndMeasurmentV20Type
public boolean isObservationAndMeasurmentV20Type()
Description copied from interface:ObservationEncoderIndicator whether the ObservationEncoder of type or subtype Observation & Measurement 2.0- Specified by:
isObservationAndMeasurmentV20Typein interfaceObservationEncoder<BinaryAttachmentResponse,Object>- Returns:
- Of type or not
-
shouldObservationsWithSameXBeMerged
public boolean shouldObservationsWithSameXBeMerged()
Description copied from interface:ObservationEncoderIndicator whether the single observations with the same procedure, observableProperty and featureOfInterest should be merged to one observation.- Specified by:
shouldObservationsWithSameXBeMergedin interfaceObservationEncoder<BinaryAttachmentResponse,Object>- Returns:
- Merge or not
-
supportsResultStreamingForMergedValues
public boolean supportsResultStreamingForMergedValues()
- Specified by:
supportsResultStreamingForMergedValuesin interfaceObservationEncoder<BinaryAttachmentResponse,Object>
-
getSupportedResponseFormats
public Set<String> getSupportedResponseFormats(String service, String version)
Description copied from interface:ObservationEncoderGet the supported response formats for this ObservationEncoder and the specified service and version.- Specified by:
getSupportedResponseFormatsin interfaceObservationEncoder<BinaryAttachmentResponse,Object>- Parameters:
service- the serviceversion- the version- Returns:
- the response formats
-
getSupportedResponseFormatObservationTypes
public Map<String,Set<SupportedType>> getSupportedResponseFormatObservationTypes()
- Specified by:
getSupportedResponseFormatObservationTypesin interfaceObservationEncoder<BinaryAttachmentResponse,Object>
-
-