use of net.opengis.swe.x101.DataComponentPropertyType 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 net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldText.
@Test
public void should_encode_Datarecord_with_fieldText() throws EncodingException {
final String field1Name = "test-name";
final String field1Value = "test-value";
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(xbDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetText(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getText().getValue(), is(field1Value));
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldBoolean.
@Test
public void should_encode_Datarecord_with_fieldBoolean() throws EncodingException {
final String field1Name = "test-name";
final boolean field1Value = true;
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweBoolean().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(xbDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetBoolean(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getBoolean().getValue(), is(field1Value));
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCount.
@Test
public void should_encode_Datarecord_with_fieldCount() throws EncodingException {
final String field1Name = "test-name";
final int field1Value = 52;
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCount().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(xbDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetCount(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getCount().getValue(), is(BigInteger.valueOf(field1Value)));
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldTime.
@Test
public void should_encode_Datarecord_with_fieldTime() throws EncodingException {
final String field1Name = "test-name";
final DateTime field1Value = new DateTime(System.currentTimeMillis());
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweTime().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(xbDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetTime(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
final DateTime xbTime = new DateTime(((XmlCalendar) field1.getTime().getValue()).getTimeInMillis(), DateTimeZone.UTC);
assertThat(xbTime.toDateTime(field1Value.getZone()), is(field1Value));
}
Aggregations