Search in sources :

Example 1 with DataComponentPropertyType

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;
}
Also used : DataRecordType(net.opengis.swe.x101.DataRecordType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) SweField(org.n52.shetland.ogc.swe.SweField) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType)

Example 2 with DataComponentPropertyType

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));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 3 with DataComponentPropertyType

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));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 4 with DataComponentPropertyType

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()));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue) Test(org.junit.Test)

Example 5 with DataComponentPropertyType

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;
}
Also used : BigInteger(java.math.BigInteger) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) DataArrayType(net.opengis.swe.x101.DataArrayType)

Aggregations

DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)12 DataRecordType (net.opengis.swe.x101.DataRecordType)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 XmlObject (org.apache.xmlbeans.XmlObject)9 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)9 SweField (org.n52.shetland.ogc.swe.SweField)8 Test (org.junit.Test)7 DataArrayType (net.opengis.swe.x101.DataArrayType)3 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)3 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)3 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)3 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3 DataArrayDocument (net.opengis.swe.x101.DataArrayDocument)2 DateTime (org.joda.time.DateTime)2 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2