use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createDataRecord.
// TODO check types for SWE101
private DataRecordType createDataRecord(SweDataRecord sosDataRecord) throws EncodingException {
List<SweField> sosFields = sosDataRecord.getFields();
DataRecordType xbDataRecord = DataRecordType.Factory.newInstance(getXmlOptions());
if (sosDataRecord.isSetDefinition()) {
xbDataRecord.setDefinition(sosDataRecord.getDefinition());
}
if (sosDataRecord.isSetFields()) {
DataComponentPropertyType[] xbFields = new DataComponentPropertyType[sosFields.size()];
int xbFieldIndex = 0;
for (SweField sosSweField : sosFields) {
DataComponentPropertyType xbField = createField(sosSweField);
xbFields[xbFieldIndex] = xbField;
xbFieldIndex++;
}
xbDataRecord.setFieldArray(xbFields);
}
return xbDataRecord;
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldQuantity.
@Test
public void should_encode_Datarecord_with_fieldQuantity() throws EncodingException {
final String field1Name = "test-name";
final double field1Value = 52.0;
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweQuantity().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.isSetQuantity(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getQuantity().getValue(), is(field1Value));
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCategory.
@Test
public void should_encode_Datarecord_with_fieldCategory() throws EncodingException {
final String field1Name = "test-name";
final String field1Value = "test-value";
final String codeSpace = "test-codespace";
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCategory().setCodeSpace(codeSpace).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.isSetCategory(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getCategory().getValue(), is(field1Value));
assertThat(field1.getCategory().getCodeSpace().getHref(), is(codeSpace));
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldTimeRange.
@Test
public void should_encode_Datarecord_with_fieldTimeRange() throws EncodingException {
final String field1Name = "test-name";
final RangeValue<DateTime> field1Value = new RangeValue<DateTime>();
final long now = System.currentTimeMillis();
final DateTime rangeStart = new DateTime(now - 1000);
final DateTime rangeEnd = new DateTime(now + 1000);
field1Value.setRangeStart(rangeStart);
field1Value.setRangeEnd(rangeEnd);
final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweTimeRange().setValue(field1Value))));
assertThat(encode, is(instanceOf(DataRecordType.class)));
final DataRecordType xbDataRecord = (DataRecordType) encode;
assertThat(xbDataRecord.getFieldArray().length, is(1));
final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
assertThat(field1.isSetTimeRange(), is(TRUE));
final DateTime xbTimeRangeStart = new DateTime(((XmlCalendar) field1.getTimeRange().getValue().get(0)).getTimeInMillis());
final DateTime xbTimeRangeEnd = new DateTime(((XmlCalendar) field1.getTimeRange().getValue().get(1)).getTimeInMillis());
assertThat(field1.getName(), is(field1Name));
assertThat(xbTimeRangeStart, is(field1Value.getRangeStart()));
assertThat(xbTimeRangeEnd, is(field1Value.getRangeEnd()));
}
use of net.opengis.swe.x101.DataComponentPropertyType in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method getDataArray.
private DataArrayType getDataArray() {
DataArrayType dataArray = DataArrayType.Factory.newInstance();
dataArray.addNewElementCount().addNewCount().setValue(new BigInteger("1"));
DataComponentPropertyType addNewElementType = dataArray.addNewElementType();
addNewElementType.setName("elementType");
addNewElementType.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
return dataArray;
}
Aggregations