Search in sources :

Example 6 with AnyScalarPropertyType

use of net.opengis.swe.x20.AnyScalarPropertyType 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.Test)

Example 7 with AnyScalarPropertyType

use of net.opengis.swe.x20.AnyScalarPropertyType 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.Test)

Example 8 with AnyScalarPropertyType

use of net.opengis.swe.x20.AnyScalarPropertyType 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.Test)

Example 9 with AnyScalarPropertyType

use of net.opengis.swe.x20.AnyScalarPropertyType 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.Test)

Example 10 with AnyScalarPropertyType

use of net.opengis.swe.x20.AnyScalarPropertyType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldQuantity.

@Test
public void should_encode_simpleDatarecord_with_fieldQuantity() throws EncodingException {
    final String name = "field-1";
    final double value = 42.5;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweQuantity().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.isSetQuantity(), is(TRUE));
    assertThat(field1.getQuantity().getValue(), is(value));
}
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.Test)

Aggregations

AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)12 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)10 XmlObject (org.apache.xmlbeans.XmlObject)10 SweField (org.n52.shetland.ogc.swe.SweField)10 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)9 Test (org.junit.Test)8 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)3 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)3 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)2 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)2 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)2 StringOrRefType (net.opengis.gml.StringOrRefType)1 Characteristics (net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics)1 AbstractDataComponentType (net.opengis.swe.x101.AbstractDataComponentType)1 AbstractDataComponentDocument (net.opengis.swe.x20.AbstractDataComponentDocument)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1 AnyScalarPropertyType (net.opengis.swe.x20.AnyScalarPropertyType)1 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)1 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)1