Search in sources :

Example 1 with Encoding

use of net.opengis.swe.x20.DataArrayType.Encoding in project arctic-sea by 52North.

the class GetResultTemplateResponseEncoder method createResultStructure.

private ResultStructure createResultStructure(SosResultStructure resultStructure) throws EncodingException {
    // TODO move encoding to SWECommonEncoder
    final DataRecordDocument dataRecordDoc;
    if (resultStructure.isEncoded()) {
        try {
            dataRecordDoc = DataRecordDocument.Factory.parse(resultStructure.getXml().get());
        } catch (XmlException ex) {
            throw unsupportedResultStructure(ex);
        }
    } else {
        XmlObject xml = encodeSwe(EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT), resultStructure.get().get());
        if (xml instanceof DataRecordDocument) {
            dataRecordDoc = (DataRecordDocument) xml;
        } else {
            throw unsupportedResultStructure();
        }
    }
    ResultStructure xbResultStructure = ResultStructure.Factory.newInstance(getXmlOptions());
    xbResultStructure.addNewAbstractDataComponent().set(dataRecordDoc.getDataRecord());
    XmlHelper.substituteElement(xbResultStructure.getAbstractDataComponent(), dataRecordDoc.getDataRecord());
    return xbResultStructure;
}
Also used : ResultStructure(net.opengis.sos.x20.GetResultTemplateResponseType.ResultStructure) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) DataRecordDocument(net.opengis.swe.x20.DataRecordDocument)

Example 2 with Encoding

use of net.opengis.swe.x20.DataArrayType.Encoding in project arctic-sea by 52North.

the class SweCommonEncoderv20 method createValues.

private XmlString createValues(List<List<String>> values, SweAbstractEncoding encoding) {
    // TODO How to deal with the decimal separator - is it an issue here?
    SweTextEncoding textEncoding = (SweTextEncoding) encoding;
    String valueString = values.stream().map(block -> String.join(textEncoding.getTokenSeparator(), block)).collect(joining(textEncoding.getBlockSeparator()));
    // create XB result object
    XmlString xmlString = XmlString.Factory.newInstance(getXmlOptions());
    xmlString.setStringValue(valueString);
    return xmlString;
}
Also used : OGCConstants(org.n52.shetland.ogc.OGCConstants) SweAllowedValues(org.n52.shetland.ogc.swe.simpleType.SweAllowedValues) CategoryPropertyType(net.opengis.swe.x20.CategoryPropertyType) CategoryRangeDocument(net.opengis.swe.x20.CategoryRangeDocument) Arrays(java.util.Arrays) VectorType(net.opengis.swe.x20.VectorType) CountPropertyType(net.opengis.swe.x20.CountPropertyType) SosConstants(org.n52.shetland.ogc.sos.SosConstants) CountRangeType(net.opengis.swe.x20.CountRangeType) TimeDocument(net.opengis.swe.x20.TimeDocument) VectorPropertyType(net.opengis.swe.x20.VectorPropertyType) Show(org.n52.shetland.w3c.xlink.Show) Map(java.util.Map) BigInteger(java.math.BigInteger) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) VectorDocument(net.opengis.swe.x20.VectorDocument) SweAllowedTokens(org.n52.shetland.ogc.swe.simpleType.SweAllowedTokens) EncodingException(org.n52.svalbard.encode.exception.EncodingException) TimeRangePropertyType(net.opengis.swe.x20.TimeRangePropertyType) TimeRangeType(net.opengis.swe.x20.TimeRangeType) DataArrayPropertyType(net.opengis.swe.x20.DataArrayPropertyType) Actuate(org.n52.shetland.w3c.xlink.Actuate) Set(java.util.Set) Encoding(net.opengis.swe.x20.DataArrayType.Encoding) Collectors.joining(java.util.stream.Collectors.joining) BooleanDocument(net.opengis.swe.x20.BooleanDocument) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) NcName(org.n52.janmayen.NcName) TextEncodingType(net.opengis.swe.x20.TextEncodingType) SchemaLocation(org.n52.shetland.w3c.SchemaLocation) QuantityRangeDocument(net.opengis.swe.x20.QuantityRangeDocument) CategoryRangePropertyType(net.opengis.swe.x20.CategoryRangePropertyType) TimeType(net.opengis.swe.x20.TimeType) RangeValue(org.n52.shetland.ogc.swe.RangeValue) TimePropertyType(net.opengis.swe.x20.TimePropertyType) SmlPosition(org.n52.shetland.ogc.sensorML.elements.SmlPosition) SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) CountType(net.opengis.swe.x20.CountType) TextDocument(net.opengis.swe.x20.TextDocument) SwesConstants(org.n52.shetland.ogc.swes.SwesConstants) XmlHelper(org.n52.svalbard.util.XmlHelper) ArrayList(java.util.ArrayList) SweCategoryRange(org.n52.shetland.ogc.swe.simpleType.SweCategoryRange) QuantityType(net.opengis.swe.x20.QuantityType) DateTimeHelper(org.n52.shetland.util.DateTimeHelper) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) QuantityRangePropertyType(net.opengis.swe.x20.QuantityRangePropertyType) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) DataChoicePropertyType(net.opengis.swe.x20.DataChoicePropertyType) MatrixDocument(net.opengis.swe.x20.MatrixDocument) QuantityRangeType(net.opengis.swe.x20.QuantityRangeType) MatrixPropertyType(net.opengis.swe.x20.MatrixPropertyType) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) SweDataComponentVisitor(org.n52.shetland.ogc.swe.SweDataComponentVisitor) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) DataRecordPropertyType(net.opengis.swe.x20.DataRecordPropertyType) Coordinate(net.opengis.swe.x20.VectorType.Coordinate) UnitReference(net.opengis.swe.x20.UnitReference) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) ShowType(org.w3.x1999.xlink.ShowType) SweField(org.n52.shetland.ogc.swe.SweField) XmlException(org.apache.xmlbeans.XmlException) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) AbstractDataComponentType(net.opengis.swe.x20.AbstractDataComponentType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) BooleanType(net.opengis.swe.x20.BooleanType) XmlString(org.apache.xmlbeans.XmlString) DataChoiceType(net.opengis.swe.x20.DataChoiceType) AllowedTokensPropertyType(net.opengis.swe.x20.AllowedTokensPropertyType) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) LoggerFactory(org.slf4j.LoggerFactory) DataArrayType(net.opengis.swe.x20.DataArrayType) TextEncodingDocument(net.opengis.swe.x20.TextEncodingDocument) SweAbstractEncoding(org.n52.shetland.ogc.swe.encoding.SweAbstractEncoding) SweVector(org.n52.shetland.ogc.swe.SweVector) DataRecordType(net.opengis.swe.x20.DataRecordType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) AllowedTimesType(net.opengis.swe.x20.AllowedTimesType) CountRangePropertyType(net.opengis.swe.x20.CountRangePropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) UoM(org.n52.shetland.ogc.UoM) URI(java.net.URI) ConformanceClass(org.n52.svalbard.ConformanceClass) AllowedTokensType(net.opengis.swe.x20.AllowedTokensType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) CategoryType(net.opengis.swe.x20.CategoryType) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) AllowedValuesType(net.opengis.swe.x20.AllowedValuesType) Collection(java.util.Collection) CategoryRangeType(net.opengis.swe.x20.CategoryRangeType) ConformanceClasses(org.n52.svalbard.ConformanceClasses) List(java.util.List) QualityPropertyType(net.opengis.swe.x20.QualityPropertyType) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) AllowedValuesPropertyType(net.opengis.swe.x20.AllowedValuesPropertyType) SmlFeatureOfInterest(org.n52.shetland.ogc.sensorML.v20.SmlFeatureOfInterest) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) AbstractEncodingType(net.opengis.swe.x20.AbstractEncodingType) DataRecordDocument(net.opengis.swe.x20.DataRecordDocument) QuantityDocument(net.opengis.swe.x20.QuantityDocument) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) Nillable(org.n52.shetland.w3c.Nillable) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) StreamingSweDataArray(org.n52.shetland.ogc.swe.stream.StreamingSweDataArray) SmlDataInterface(org.n52.shetland.ogc.sensorML.v20.SmlDataInterface) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) QuantityPropertyType(net.opengis.swe.x20.QuantityPropertyType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) HashSet(java.util.HashSet) Referenceable(org.n52.shetland.w3c.xlink.Referenceable) AllowedTimesPropertyType(net.opengis.swe.x20.AllowedTimesPropertyType) SweQuality(org.n52.shetland.ogc.swe.simpleType.SweQuality) TextPropertyType(net.opengis.swe.x20.TextPropertyType) SweConstants(org.n52.shetland.ogc.swe.SweConstants) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) XmlObject(org.apache.xmlbeans.XmlObject) TextType(net.opengis.swe.x20.TextType) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty) CountDocument(net.opengis.swe.x20.CountDocument) TimeRangeDocument(net.opengis.swe.x20.TimeRangeDocument) Logger(org.slf4j.Logger) DataChoiceDocument(net.opengis.swe.x20.DataChoiceDocument) DateTime(org.joda.time.DateTime) MatrixType(net.opengis.swe.x20.MatrixType) CategoryDocument(net.opengis.swe.x20.CategoryDocument) CountRangeDocument(net.opengis.swe.x20.CountRangeDocument) AbstractEncodingDocument(net.opengis.swe.x20.AbstractEncodingDocument) CodingHelper(org.n52.svalbard.util.CodingHelper) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Field(net.opengis.swe.x20.DataRecordType.Field) Collections(java.util.Collections) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument) XmlString(org.apache.xmlbeans.XmlString) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) XmlString(org.apache.xmlbeans.XmlString)

Example 3 with Encoding

use of net.opengis.swe.x20.DataArrayType.Encoding in project arctic-sea by 52North.

the class GetResultTemplateResponseEncoder method createResultEncoding.

private ResultEncoding createResultEncoding(SosResultEncoding resultEncoding) throws EncodingException {
    // TODO move encoding to SWECommonEncoder
    final TextEncodingDocument xbEncoding;
    if (resultEncoding.isEncoded()) {
        try {
            xbEncoding = TextEncodingDocument.Factory.parse(resultEncoding.getXml().get());
        } catch (XmlException ex) {
            throw unsupportedResultEncoding(ex);
        }
    } else {
        XmlObject xml = encodeSwe(EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT), resultEncoding.get().get());
        if (xml instanceof TextEncodingDocument) {
            xbEncoding = (TextEncodingDocument) xml;
        } else {
            throw unsupportedResultEncoding();
        }
    }
    ResultEncoding xbResultEncoding = ResultEncoding.Factory.newInstance(getXmlOptions());
    xbResultEncoding.addNewAbstractEncoding().set(xbEncoding.getTextEncoding());
    XmlHelper.substituteElement(xbResultEncoding.getAbstractEncoding(), xbEncoding.getTextEncoding());
    return xbResultEncoding;
}
Also used : TextEncodingDocument(net.opengis.swe.x20.TextEncodingDocument) XmlException(org.apache.xmlbeans.XmlException) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) ResultEncoding(net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding) XmlObject(org.apache.xmlbeans.XmlObject)

Aggregations

XmlException (org.apache.xmlbeans.XmlException)3 XmlObject (org.apache.xmlbeans.XmlObject)3 DataRecordDocument (net.opengis.swe.x20.DataRecordDocument)2 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 BigInteger (java.math.BigInteger)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors.joining (java.util.stream.Collectors.joining)1 ResultEncoding (net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding)1 ResultStructure (net.opengis.sos.x20.GetResultTemplateResponseType.ResultStructure)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1