Search in sources :

Example 11 with SimpleDataRecordType

use of org.geotoolkit.swe.xml.v101.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)

Example 12 with SimpleDataRecordType

use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCategory.

@Test
public void should_encode_simpleDatarecord_with_fieldCategory() throws EncodingException {
    final String name = "field-1";
    final String value = "field-1-value";
    final String codeSpace = "field-1-codespace";
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCategory().setValue(value).setCodeSpace(codeSpace))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetCategory(), is(TRUE));
    assertThat(field1.getName(), is(name));
    assertThat(field1.getCategory().getValue(), is(value));
    assertThat(field1.getCategory().isSetCodeSpace(), is(TRUE));
    assertThat(field1.getCategory().getCodeSpace().isSetHref(), is(TRUE));
}
Also used : SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) XmlObject(org.apache.xmlbeans.XmlObject) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.jupiter.api.Test)

Example 13 with SimpleDataRecordType

use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldBoolean.

@Test
public void should_encode_simpleDatarecord_with_fieldBoolean() throws EncodingException {
    final String field1Name = "field-1";
    final Boolean field1Value = Boolean.TRUE;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweBoolean().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.isSetBoolean(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getBoolean().getValue(), is(field1Value));
}
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) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.jupiter.api.Test)

Example 14 with SimpleDataRecordType

use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_quantities.

@Test
public void should_encode_simpleDatarecord_with_quantities() throws EncodingException {
    final String name = "field-1";
    final String unit = "m";
    final Double value = 1.1;
    final String name2 = "field-2";
    final String unit2 = "urn:ogc:def:uom:UCUM::m";
    final Double value2 = 1.2;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweQuantity().setUom(unit).setValue(value))).addField(new SweField(name2, new SweQuantity().setUom(unit2).setValue(value2))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(2));
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    final AnyScalarPropertyType field2 = xbSimpleDataRecord.getFieldArray(1);
    // unit in code
    assertThat(field1.getName(), is(name));
    assertThat(field1.isSetQuantity(), is(TRUE));
    assertThat(field1.getQuantity().getValue(), is(value));
    assertThat(field1.getQuantity().getUom().getCode(), is(unit));
    // unit in href
    assertThat(field2.getName(), is(name2));
    assertThat(field2.isSetQuantity(), is(TRUE));
    assertThat(field2.getQuantity().getValue(), is(value2));
    assertThat(field2.getQuantity().getUom().getHref(), is(unit2));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) 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.jupiter.api.Test)

Example 15 with SimpleDataRecordType

use of org.geotoolkit.swe.xml.v101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldTime.

@Test
public void should_encode_simpleDatarecord_with_fieldTime() throws EncodingException {
    final String name = "field-1";
    final DateTime value = new DateTime(DateTimeZone.UTC);
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweTime().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.isSetTime(), is(TRUE));
    assertThat(DateTimeHelper.parseIsoString2DateTime(field1.getTime().getValue().toString()).toString(), is(value.toString()));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) 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) DateTime(org.joda.time.DateTime) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)15 Test (org.junit.jupiter.api.Test)12 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)11 SweField (org.n52.shetland.ogc.swe.SweField)11 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)10 XmlObject (org.apache.xmlbeans.XmlObject)9 ArrayList (java.util.ArrayList)4 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)4 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)3 SystemType (net.opengis.sensorML.x101.SystemType)3 AnyScalarPropertyType (org.geotoolkit.swe.xml.v101.AnyScalarPropertyType)3 DataArrayType (org.geotoolkit.swe.xml.v101.DataArrayType)3 PhenomenonType (org.geotoolkit.swe.xml.v101.PhenomenonType)3 SimpleDataRecordType (org.geotoolkit.swe.xml.v101.SimpleDataRecordType)3 Text (org.geotoolkit.swe.xml.v101.Text)3 TextBlockType (org.geotoolkit.swe.xml.v101.TextBlockType)3 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)3 StringWriter (java.io.StringWriter)2 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)2 FeaturePropertyType (org.geotoolkit.gml.xml.v311.FeaturePropertyType)2