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;
}
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());
}
}
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;
}
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;
}
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)));
}
Aggregations