Search in sources :

Example 1 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createSimpleDataRecord.

private SimpleDataRecordType createSimpleDataRecord(SweSimpleDataRecord simpleDataRecord) throws EncodingException {
    SimpleDataRecordType xbSimpleDataRecord = SimpleDataRecordType.Factory.newInstance(getXmlOptions());
    if (simpleDataRecord.isSetDefinition()) {
        xbSimpleDataRecord.setDefinition(simpleDataRecord.getDefinition());
    }
    if (simpleDataRecord.isSetDescription()) {
        StringOrRefType xbSoR = StringOrRefType.Factory.newInstance();
        xbSoR.setStringValue(simpleDataRecord.getDefinition());
        xbSimpleDataRecord.setDescription(xbSoR);
    }
    if (simpleDataRecord.isSetFields()) {
        AnyScalarPropertyType[] xbFields = new AnyScalarPropertyType[simpleDataRecord.getFields().size()];
        int xbFieldIndex = 0;
        for (SweField sweField : simpleDataRecord.getFields()) {
            AnyScalarPropertyType xbField = createFieldForSimpleDataRecord(sweField);
            xbFields[xbFieldIndex] = xbField;
            xbFieldIndex++;
        }
        xbSimpleDataRecord.setFieldArray(xbFields);
    }
    return xbSimpleDataRecord;
}
Also used : StringOrRefType(net.opengis.gml.StringOrRefType) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SweField(org.n52.shetland.ogc.swe.SweField) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType)

Example 2 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldText.

@Test
public void should_encode_simpleDatarecord_with_fieldText() throws EncodingException {
    final String field1Name = "field-1";
    final String field1Value = "field-1-value";
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetText(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getText().getValue(), is(field1Value));
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 3 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCount.

@Test
public void should_encode_simpleDatarecord_with_fieldCount() throws EncodingException {
    final String name = "field-1";
    final int value = 42;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCount().setValue(value))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.getName(), is(name));
    assertThat(field1.isSetCount(), is(TRUE));
    assertThat(field1.getCount().getValue().intValue(), is(value));
}
Also used : SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 4 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_features_of_interest_from_sml.

@Test
public void should_decode_features_of_interest_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    Capabilities xbCapabilities = xbSystem.addNewCapabilities();
    xbCapabilities.setName(SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST);
    SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_1, TEST_NAME_1);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_2, TEST_NAME_2);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    // assertThat(absProcess.getFeaturesOfInterest().size(), is(2));
    assertThat(absProcess.getCapabilities().size(), is(1));
// List<String> featuresOfInterest = new ArrayList<String>(absProcess.getFeaturesOfInterest());
// Collections.sort(featuresOfInterest);
// assertThat(featuresOfInterest.get(0), is(TEST_ID_1));
// assertThat(featuresOfInterest.get(1), is(TEST_ID_2));
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SystemType(net.opengis.sensorML.x101.SystemType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 5 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method encodeSimpleDataRecord.

private SimpleDataRecordType encodeSimpleDataRecord(final SystemType xbSystem, final String capName, final int fields) {
    assertThat(xbSystem.getCapabilitiesArray().length, is(1));
    final Capabilities xbCapabilities = xbSystem.getCapabilitiesArray()[0];
    assertThat(xbCapabilities.getName(), is(capName));
    assertThat(xbCapabilities.getAbstractDataRecord(), notNullValue());
    assertThat(xbCapabilities.getAbstractDataRecord(), instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.getAbstractDataRecord();
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(fields));
    return xbSimpleDataRecord;
}
Also used : Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType)

Aggregations

SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)14 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)11 Test (org.junit.Test)11 SweField (org.n52.shetland.ogc.swe.SweField)10 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)9 XmlObject (org.apache.xmlbeans.XmlObject)8 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)4 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)3 SystemType (net.opengis.sensorML.x101.SystemType)3 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)2 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)2 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)2 StringOrRefType (net.opengis.gml.StringOrRefType)1 Characteristics (net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics)1 DateTime (org.joda.time.DateTime)1 SmlCharacteristics (org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics)1 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)1 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)1