Search in sources :

Example 6 with DataComponentPropertyType

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;
}
Also used : NotYetSupportedDecodingException(org.n52.svalbard.decode.exception.NotYetSupportedDecodingException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Example 7 with DataComponentPropertyType

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

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));
}
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) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 9 with DataComponentPropertyType

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)));
}
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) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 10 with DataComponentPropertyType

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));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) 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) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

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