Search in sources :

Example 11 with DataRecord

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

the class SensorMLDecoderV101Test method should_decode_io_from_sml.

@Test
public void should_decode_io_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    InputList xbInputList = xbSystem.addNewInputs().addNewInputList();
    OutputList xbOutputList = xbSystem.addNewOutputs().addNewOutputList();
    IoComponentPropertyType input1 = xbInputList.addNewInput();
    input1.setName("input1");
    input1.addNewBoolean();
    IoComponentPropertyType input2 = xbInputList.addNewInput();
    input2.setName("input2");
    input2.addNewCount();
    IoComponentPropertyType output1 = xbOutputList.addNewOutput();
    output1.setName("output1");
    output1.addNewQuantity();
    IoComponentPropertyType output2 = xbOutputList.addNewOutput();
    output2.setName("output2");
    DataArrayType dataArray = getDataArray();
    output2.setAbstractDataArray1(dataArray);
    XmlHelper.substituteElement(output2.getAbstractDataArray1(), dataArray);
    IoComponentPropertyType output3 = xbOutputList.addNewOutput();
    output3.setName("output3");
    DataRecordType dataRecord = DataRecordType.Factory.newInstance();
    output3.setAbstractDataRecord(dataRecord);
    XmlHelper.substituteElement(output3.getAbstractDataRecord(), dataRecord);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getInputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Boolean));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Boolean));
    assertThat(absProcess.getInputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.Count));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(1).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Count));
    assertThat(absProcess.getOutputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Quantity));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getOutputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Quantity));
    assertThat(absProcess.getOutputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.DataArray));
    assertThat(absProcess.getOutputs().get(2).getIoValue().getDataComponentType(), is(SweDataComponentType.DataRecord));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) IoComponentPropertyType(net.opengis.sensorML.x101.IoComponentPropertyType) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList) DataArrayType(net.opengis.swe.x101.DataArrayType) Test(org.junit.Test)

Example 12 with DataRecord

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

the class WmlTDREncoderv20 method createDataRecord.

/**
 * Create a SOS DataRecord object from SOS observation and encode to
 * XmlBeans object
 *
 * @param sosObservation
 *            SOS observation
 * @return XML DataRecord object
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createDataRecord(OmObservation sosObservation) throws EncodingException {
    AbstractPhenomenon observableProperty = sosObservation.getObservationConstellation().getObservableProperty();
    SweQuantity quantity = new SweQuantity();
    quantity.setDefinition(observableProperty.getIdentifier());
    quantity.setDescription(observableProperty.getDescription());
    if (observableProperty instanceof OmObservableProperty && ((OmObservableProperty) observableProperty).isSetUnit()) {
        quantity.setUom(((OmObservableProperty) observableProperty).getUnit());
    }
    return createDataRecord(quantity, sosObservation.getObservationID());
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Aggregations

SweField (org.n52.shetland.ogc.swe.SweField)5 Test (org.junit.Test)4 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)4 XmlObject (org.apache.xmlbeans.XmlObject)2 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)2 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)2 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)1 InputList (net.opengis.sensorML.x101.InputsDocument.Inputs.InputList)1 IoComponentPropertyType (net.opengis.sensorML.x101.IoComponentPropertyType)1 OutputList (net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList)1 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)1 SystemType (net.opengis.sensorML.x101.SystemType)1 DataArrayType (net.opengis.swe.x101.DataArrayType)1 DataRecordType (net.opengis.swe.x101.DataRecordType)1 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)1 AbstractPhenomenon (org.n52.shetland.ogc.om.AbstractPhenomenon)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1 ComplexValue (org.n52.shetland.ogc.om.values.ComplexValue)1 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)1