Search in sources :

Example 11 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class GetResultTemplateResponseEncoder method encodeResultEncoding.

private void encodeResultEncoding(GetResultTemplateResponse t, ObjectNode json) throws EncodingException {
    ObjectNode jre = json.putObject(JSONConstants.RESULT_ENCODING);
    SweAbstractEncoding encoding = null;
    SosResultEncoding re = t.getResultEncoding();
    if (re.isDecoded()) {
        encoding = t.getResultEncoding().get().get();
    } else {
        try {
            XmlNamespaceDecoderKey key = new XmlNamespaceDecoderKey(SweConstants.NS_SWE_20, SweAbstractEncoding.class);
            Decoder<SweAbstractEncoding, XmlObject> decoder = this.decoderRepository.getDecoder(key);
            if (decoder == null) {
                throw new NoDecoderForKeyException(key);
            }
            encoding = decoder.decode(XmlObject.Factory.parse(re.getXml().get()));
        } catch (XmlException | DecodingException ex) {
            throw new EncodingException(ex);
        }
    }
    if (encoding instanceof SweTextEncoding) {
        encodeSweTextEncoding(encoding, jre);
    } else {
        LOG.warn("Unsupported encoding: {}", encoding == null ? null : encoding.getClass());
    }
}
Also used : NoDecoderForKeyException(org.n52.svalbard.decode.exception.NoDecoderForKeyException) XmlNamespaceDecoderKey(org.n52.svalbard.decode.XmlNamespaceDecoderKey) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) EncodingException(org.n52.svalbard.encode.exception.EncodingException) SweAbstractEncoding(org.n52.shetland.ogc.swe.encoding.SweAbstractEncoding) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding)

Example 12 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class SweCommonEncoderv20Test method shouldEncodeTextEncoding.

@Test
public void shouldEncodeTextEncoding() throws EncodingException {
    String tokenSeparator = "@";
    String blockSeparator = ";";
    SweTextEncoding textEncoding = new SweTextEncoding();
    textEncoding.setBlockSeparator(blockSeparator);
    textEncoding.setTokenSeparator(tokenSeparator);
    XmlObject encodedEncoding = sweCommonEncoderv20.encode(textEncoding);
    Assert.assertThat(encodedEncoding, Matchers.instanceOf(TextEncodingType.class));
    TextEncodingType xbTextEncoding = (TextEncodingType) encodedEncoding;
    Assert.assertThat(xbTextEncoding.getBlockSeparator(), Is.is(blockSeparator));
    Assert.assertThat(xbTextEncoding.getTokenSeparator(), Is.is(tokenSeparator));
}
Also used : TextEncodingType(net.opengis.swe.x20.TextEncodingType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Example 13 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createValues.

private XmlString createValues(SweTextEncoding textEncoding, List<List<String>> values) {
    // TODO How to deal with the decimal separator - is it an issue here?
    // textEncoding.getDecimalSeparator();
    String tokenSeparator = textEncoding.getTokenSeparator();
    String blockSeparator = textEncoding.getBlockSeparator();
    String valueString = values.stream().map(block -> String.join(tokenSeparator, block)).collect(joining(blockSeparator));
    // create XB result object
    XmlString xbValueString = XmlString.Factory.newInstance();
    xbValueString.setStringValue(valueString);
    return xbValueString;
}
Also used : SweAllowedValues(org.n52.shetland.ogc.swe.simpleType.SweAllowedValues) GDateBuilder(org.apache.xmlbeans.GDateBuilder) DataRecordDocument(net.opengis.swe.x101.DataRecordDocument) AbstractEncodingType(net.opengis.swe.x101.AbstractEncodingType) Show(org.n52.shetland.w3c.xlink.Show) Map(java.util.Map) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument) BigInteger(java.math.BigInteger) Quantity(net.opengis.swe.x101.QuantityDocument.Quantity) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) VectorType(net.opengis.swe.x101.VectorType) SweAllowedTokens(org.n52.shetland.ogc.swe.simpleType.SweAllowedTokens) EncodingException(org.n52.svalbard.encode.exception.EncodingException) AllowedTokensPropertyType(net.opengis.swe.x101.AllowedTokensPropertyType) Actuate(org.n52.shetland.w3c.xlink.Actuate) Set(java.util.Set) Collectors.joining(java.util.stream.Collectors.joining) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) SchemaLocation(org.n52.shetland.w3c.SchemaLocation) AllowedTokens(net.opengis.swe.x101.AllowedTokensDocument.AllowedTokens) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) QName(javax.xml.namespace.QName) RangeValue(org.n52.shetland.ogc.swe.RangeValue) Joiner(com.google.common.base.Joiner) SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) UomPropertyType(net.opengis.swe.x101.UomPropertyType) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) XmlCursor(org.apache.xmlbeans.XmlCursor) XmlHelper(org.n52.svalbard.util.XmlHelper) ArrayList(java.util.ArrayList) Time(net.opengis.swe.x101.TimeDocument.Time) DateTimeHelper(org.n52.shetland.util.DateTimeHelper) Lists(com.google.common.collect.Lists) BlockEncodingPropertyType(net.opengis.swe.x101.BlockEncodingPropertyType) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) TimeGeometricPrimitivePropertyType(net.opengis.swe.x101.TimeGeometricPrimitivePropertyType) QuantityRange(net.opengis.swe.x101.QuantityRangeDocument.QuantityRange) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) ShowType(org.w3.x1999.xlink.ShowType) TimeRange(net.opengis.swe.x101.TimeRangeDocument.TimeRange) SweField(org.n52.shetland.ogc.swe.SweField) XmlException(org.apache.xmlbeans.XmlException) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) Count(net.opengis.swe.x101.CountDocument.Count) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordType(net.opengis.swe.x101.DataRecordType) Category(net.opengis.swe.x101.CategoryDocument.Category) XmlString(org.apache.xmlbeans.XmlString) Text(net.opengis.swe.x101.TextDocument.Text) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) LoggerFactory(org.slf4j.LoggerFactory) CountRange(net.opengis.swe.x101.CountRangeDocument.CountRange) AllowedValues(net.opengis.swe.x101.AllowedValuesDocument.AllowedValues) QualityPropertyType(net.opengis.swe.x101.QualityPropertyType) SweAbstractEncoding(org.n52.shetland.ogc.swe.encoding.SweAbstractEncoding) SweVector(org.n52.shetland.ogc.swe.SweVector) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) ActuateType(org.w3.x1999.xlink.ActuateType) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) UoM(org.n52.shetland.ogc.UoM) URI(java.net.URI) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) Collection(java.util.Collection) Sets(com.google.common.collect.Sets) List(java.util.List) XmlDateTime(org.apache.xmlbeans.XmlDateTime) GmlConstants(org.n52.shetland.ogc.gml.GmlConstants) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) ObservableProperty(net.opengis.swe.x101.ObservablePropertyDocument.ObservableProperty) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) Nillable(org.n52.shetland.w3c.Nillable) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) Referenceable(org.n52.shetland.w3c.xlink.Referenceable) EnvelopeType(net.opengis.swe.x101.EnvelopeType) StringOrRefType(net.opengis.gml.StringOrRefType) SweQuality(org.n52.shetland.ogc.swe.simpleType.SweQuality) AllowedTimesPropertyType(net.opengis.swe.x101.AllowedTimesPropertyType) DataArrayType(net.opengis.swe.x101.DataArrayType) VectorPropertyType(net.opengis.swe.x101.VectorPropertyType) SweConstants(org.n52.shetland.ogc.swe.SweConstants) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) XmlObject(org.apache.xmlbeans.XmlObject) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty) AllowedTimes(net.opengis.swe.x101.AllowedTimesDocument.AllowedTimes) Logger(org.slf4j.Logger) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DateTime(org.joda.time.DateTime) TextBlock(net.opengis.swe.x101.TextBlockDocument.TextBlock) CodingHelper(org.n52.svalbard.util.CodingHelper) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Reference(org.n52.shetland.w3c.xlink.Reference) Collections(java.util.Collections) AllowedValuesPropertyType(net.opengis.swe.x101.AllowedValuesPropertyType) Coordinate(net.opengis.swe.x101.VectorType.Coordinate) XmlString(org.apache.xmlbeans.XmlString) XmlString(org.apache.xmlbeans.XmlString)

Aggregations

SweTextEncoding (org.n52.shetland.ogc.swe.encoding.SweTextEncoding)13 XmlObject (org.apache.xmlbeans.XmlObject)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Lists (com.google.common.collect.Lists)2 BigInteger (java.math.BigInteger)2 URI (java.net.URI)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors.joining (java.util.stream.Collectors.joining)2 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)2 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)2 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)2 CountPropertyType (net.opengis.swe.x20.CountPropertyType)2 DataArrayPropertyType (net.opengis.swe.x20.DataArrayPropertyType)2 DataRecordPropertyType (net.opengis.swe.x20.DataRecordPropertyType)2 QuantityPropertyType (net.opengis.swe.x20.QuantityPropertyType)2 TextEncodingDocument (net.opengis.swe.x20.TextEncodingDocument)2