Search in sources :

Example 1 with DataComponentPropertyType

use of org.geotoolkit.swe.xml.v100.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.jupiter.api.Test)

Example 2 with DataComponentPropertyType

use of org.geotoolkit.swe.xml.v100.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.jupiter.api.Test)

Example 3 with DataComponentPropertyType

use of org.geotoolkit.swe.xml.v100.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.jupiter.api.Test)

Example 4 with DataComponentPropertyType

use of org.geotoolkit.swe.xml.v100.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 5 with DataComponentPropertyType

use of org.geotoolkit.swe.xml.v100.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)13 XmlObject (org.apache.xmlbeans.XmlObject)10 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)10 DataRecordType (net.opengis.swe.x101.DataRecordType)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 ArrayList (java.util.ArrayList)8 SweField (org.n52.shetland.ogc.swe.SweField)8 Test (org.junit.jupiter.api.Test)7 InputStream (java.io.InputStream)4 DataComponentPropertyType (org.geotoolkit.swe.xml.v101.DataComponentPropertyType)4 DataRecordType (org.geotoolkit.swe.xml.v101.DataRecordType)4 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)4 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)4 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)4 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)4 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)4 StringWriter (java.io.StringWriter)3 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)3 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)3 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)3