Search in sources :

Example 6 with SweDataArray

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

the class SweCommonEncoderv101 method encode.

@Override
public XmlObject encode(Object element, EncodingContext context) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof SweAbstractSimpleType) {
        encodedObject = createSimpleType((SweAbstractSimpleType<?>) element, context);
    // }
    // if (element instanceof SweBoolean) {
    // encodedObject = createBoolean((SweBoolean) element);
    // } else if (element instanceof SweCategory) {
    // encodedObject = createCategory((SweCategory) element);
    // } else if (element instanceof SweCount) {
    // encodedObject = createCount((SweCount) element);
    // } else if (element instanceof SweObservableProperty) {
    // encodedObject = createObservableProperty((SweObservableProperty)
    // element);
    // } else if (element instanceof SweQuantity) {
    // encodedObject = createQuantity((SweQuantity) element);
    // } else if (element instanceof SweQuantityRange) {
    // encodedObject = createQuantityRange((SweQuantityRange) element);
    // } else if (element instanceof SweText) {
    // encodedObject = createText((SweText) element);
    // } else if (element instanceof SweTime) {
    // encodedObject = createTime((SweTime) element);
    // } else if (element instanceof SweTimeRange) {
    // encodedObject = createTimeRange((SweTimeRange) element);
    } else if (element instanceof SweCoordinate) {
        encodedObject = createCoordinate((SweCoordinate<?>) element);
    } else if (element instanceof SweDataArray) {
        encodedObject = createDataArray((SweDataArray) element);
    } else if (element instanceof SweDataRecord) {
        DataRecordType drt = createDataRecord((SweDataRecord) element);
        if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
            DataRecordDocument drd = DataRecordDocument.Factory.newInstance(getXmlOptions());
            drd.setDataRecord(drt);
            encodedObject = drd;
        } else {
            encodedObject = drt;
        }
    } else if (element instanceof SweEnvelope) {
        encodedObject = createEnvelope((SweEnvelope) element);
    } else if (element instanceof SweSimpleDataRecord) {
        encodedObject = createSimpleDataRecord((SweSimpleDataRecord) element);
    } else if (element instanceof TimePeriod) {
        encodedObject = createTimeGeometricPrimitivePropertyType((TimePeriod) element);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    XmlHelper.validateDocument(encodedObject, EncodingException::new);
    return encodedObject;
}
Also used : DataRecordType(net.opengis.swe.x101.DataRecordType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordDocument(net.opengis.swe.x101.DataRecordDocument) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 7 with SweDataArray

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

the class OmObservation method mergeValues.

private void mergeValues(OmObservation merged, OmObservation observation) {
    SweDataArray combinedValue = (SweDataArray) merged.getValue().getValue().getValue();
    SweDataArray v = (SweDataArray) observation.getValue().getValue().getValue();
    if (v.isSetValues()) {
        combinedValue.addAll(v.getValues());
    }
}
Also used : SweDataArray(org.n52.shetland.ogc.swe.SweDataArray)

Example 8 with SweDataArray

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

the class SweCommonDecoderV101 method parseSweDataArrayType.

private SweDataArray parseSweDataArrayType(DataArrayType xbDataArray) throws DecodingException {
    if (!xbDataArray.getElementType().isSetAbstractDataRecord()) {
        throw new DecodingException("The swe:DataArray contains a not yet supported elementType element. " + "Currently only 'swe:DataRecord' is supported as elementType element.");
    }
    final SweDataArray dataArray = new SweDataArray();
    if (xbDataArray.getElementCount() != null) {
        dataArray.setElementCount(parseElementCount(xbDataArray.getElementCount()));
    }
    // parse data record to elementType
    DataComponentPropertyType elementType = xbDataArray.getElementType();
    if (elementType != null) {
        dataArray.setElementType(parseDataComponentProperty(elementType));
    }
    if (xbDataArray.isSetEncoding()) {
        dataArray.setEncoding(parseEncoding(xbDataArray.getEncoding()));
    }
    // parse values
    // if (xbDataArray.isSetValues()) {
    // // TODO implement full support
    // // dataArray.setValues(parseValues(dataArray.getElementCount(),
    // // dataArray.getElementType(),
    // // dataArray.getEncoding(), xbDataArray.getValues()));
    // }
    DataArrayDocument xbDataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
    xbDataArrayDoc.setDataArray1(xbDataArray);
    dataArray.setXml(xbDataArrayDoc.xmlText());
    return dataArray;
}
Also used : NotYetSupportedDecodingException(org.n52.svalbard.decode.exception.NotYetSupportedDecodingException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Example 9 with SweDataArray

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

the class SweCommonDecoderV20 method parseDataArray.

private SweDataArray parseDataArray(DataArrayType xbDataArray) throws DecodingException {
    SweDataArray sosSweDataArray = new SweDataArray();
    CountPropertyType elementCount = xbDataArray.getElementCount();
    if (elementCount != null) {
        sosSweDataArray.setElementCount(parseElementCount(elementCount));
    }
    // parse data record to elementType
    DataArrayType.ElementType xbElementType = xbDataArray.getElementType();
    if (xbElementType != null && xbElementType.getAbstractDataComponent() != null) {
        sosSweDataArray.setElementType(parseAbstractDataComponent(xbElementType.getAbstractDataComponent()));
    }
    if (xbDataArray.isSetEncoding()) {
        sosSweDataArray.setEncoding(parseEncoding(xbDataArray.getEncoding().getAbstractEncoding()));
    }
    // parse values
    if (xbDataArray.isSetValues()) {
        sosSweDataArray.setValues(parseValues(sosSweDataArray.getElementCount(), sosSweDataArray.getElementType(), sosSweDataArray.getEncoding(), xbDataArray.getValues()));
    }
    // set XML
    DataArrayDocument dataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
    dataArrayDoc.setDataArray1(xbDataArray);
    sosSweDataArray.setXml(dataArrayDoc.xmlText(getXmlOptions()));
    return sosSweDataArray;
}
Also used : CountPropertyType(net.opengis.swe.x20.CountPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayType(net.opengis.swe.x20.DataArrayType) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument)

Example 10 with SweDataArray

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

the class OmEncoderv100 method addMultiObservationValueToResult.

private void addMultiObservationValueToResult(XmlObject xbResult, OmObservation sosObservation) throws EncodingException {
    SweDataArray dataArray = sweHelper.createSosSweDataArray(sosObservation);
    xbResult.set(encodeObjectToXml(SweConstants.NS_SWE_101, dataArray, EncodingContext.of(XmlBeansEncodingFlags.FOR_OBSERVATION)));
}
Also used : SweDataArray(org.n52.shetland.ogc.swe.SweDataArray)

Aggregations

SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)12 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)5 XmlObject (org.apache.xmlbeans.XmlObject)4 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)4 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)3 SweDataArrayValue (org.n52.shetland.ogc.om.values.SweDataArrayValue)3 DataArrayDocument (net.opengis.swe.x101.DataArrayDocument)2 DataArrayType (net.opengis.swe.x101.DataArrayType)2 DataRecordType (net.opengis.swe.x101.DataRecordType)2 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)2 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)2 DataArrayType (net.opengis.swe.x20.DataArrayType)2 XmlBoolean (org.apache.xmlbeans.XmlBoolean)2 XmlException (org.apache.xmlbeans.XmlException)2 XmlInteger (org.apache.xmlbeans.XmlInteger)2 XmlString (org.apache.xmlbeans.XmlString)2 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)2 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)2 BooleanValue (org.n52.shetland.ogc.om.values.BooleanValue)2 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)2