Search in sources :

Example 1 with TimeRangeDocument

use of net.opengis.swe.x101.TimeRangeDocument in project arctic-sea by 52North.

the class SweCommonEncoderv20 method asDocument.

private XmlObject asDocument(AbstractDataComponentType type) throws NotYetSupportedEncodingException {
    if (type instanceof BooleanType) {
        BooleanDocument document = BooleanDocument.Factory.newInstance();
        document.setBoolean((BooleanType) type);
        return document;
    } else if (type instanceof CountType) {
        CountDocument document = CountDocument.Factory.newInstance();
        document.setCount((CountType) type);
        return document;
    } else if (type instanceof CountRangeType) {
        CountRangeDocument document = CountRangeDocument.Factory.newInstance();
        document.setCountRange((CountRangeType) type);
        return document;
    } else if (type instanceof QuantityType) {
        QuantityDocument document = QuantityDocument.Factory.newInstance();
        document.setQuantity((QuantityType) type);
        return document;
    } else if (type instanceof QuantityRangeType) {
        QuantityRangeDocument document = QuantityRangeDocument.Factory.newInstance();
        document.setQuantityRange((QuantityRangeType) type);
        return document;
    } else if (type instanceof TimeType) {
        TimeDocument document = TimeDocument.Factory.newInstance();
        document.setTime((TimeType) type);
        return document;
    } else if (type instanceof TimeRangeType) {
        TimeRangeDocument document = TimeRangeDocument.Factory.newInstance();
        document.setTimeRange((TimeRangeType) type);
        return document;
    } else if (type instanceof CategoryType) {
        CategoryDocument document = CategoryDocument.Factory.newInstance();
        document.setCategory((CategoryType) type);
        return document;
    } else if (type instanceof CategoryRangeType) {
        CategoryRangeDocument document = CategoryRangeDocument.Factory.newInstance();
        document.setCategoryRange((CategoryRangeType) type);
        return document;
    } else if (type instanceof MatrixType) {
        MatrixDocument document = MatrixDocument.Factory.newInstance();
        document.setMatrix((MatrixType) type);
        return document;
    } else if (type instanceof DataArrayType) {
        DataArrayDocument document = DataArrayDocument.Factory.newInstance();
        document.setDataArray1((DataArrayType) type);
        return document;
    } else if (type instanceof DataChoiceType) {
        DataChoiceDocument document = DataChoiceDocument.Factory.newInstance();
        document.setDataChoice((DataChoiceType) type);
        return document;
    } else if (type instanceof DataRecordType) {
        DataRecordDocument document = DataRecordDocument.Factory.newInstance();
        document.setDataRecord((DataRecordType) type);
        return document;
    } else if (type instanceof TextType) {
        TextDocument document = TextDocument.Factory.newInstance();
        document.setText((TextType) type);
        return document;
    } else if (type instanceof VectorType) {
        VectorDocument document = VectorDocument.Factory.newInstance();
        document.setVector((VectorType) type);
        return document;
    } else {
        throw new NotYetSupportedEncodingException(type.getClass().getName(), type);
    }
}
Also used : MatrixDocument(net.opengis.swe.x20.MatrixDocument) DataRecordType(net.opengis.swe.x20.DataRecordType) CategoryRangeType(net.opengis.swe.x20.CategoryRangeType) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) TimeRangeDocument(net.opengis.swe.x20.TimeRangeDocument) CategoryType(net.opengis.swe.x20.CategoryType) CountType(net.opengis.swe.x20.CountType) QuantityDocument(net.opengis.swe.x20.QuantityDocument) TimeType(net.opengis.swe.x20.TimeType) VectorDocument(net.opengis.swe.x20.VectorDocument) CountRangeType(net.opengis.swe.x20.CountRangeType) DataChoiceType(net.opengis.swe.x20.DataChoiceType) VectorType(net.opengis.swe.x20.VectorType) DataChoiceDocument(net.opengis.swe.x20.DataChoiceDocument) CountRangeDocument(net.opengis.swe.x20.CountRangeDocument) DataArrayType(net.opengis.swe.x20.DataArrayType) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument) TextDocument(net.opengis.swe.x20.TextDocument) BooleanType(net.opengis.swe.x20.BooleanType) BooleanDocument(net.opengis.swe.x20.BooleanDocument) DataRecordDocument(net.opengis.swe.x20.DataRecordDocument) TextType(net.opengis.swe.x20.TextType) TimeRangeType(net.opengis.swe.x20.TimeRangeType) CategoryDocument(net.opengis.swe.x20.CategoryDocument) CategoryRangeDocument(net.opengis.swe.x20.CategoryRangeDocument) CountDocument(net.opengis.swe.x20.CountDocument) QuantityType(net.opengis.swe.x20.QuantityType) MatrixType(net.opengis.swe.x20.MatrixType) QuantityRangeDocument(net.opengis.swe.x20.QuantityRangeDocument) TimeDocument(net.opengis.swe.x20.TimeDocument) QuantityRangeType(net.opengis.swe.x20.QuantityRangeType)

Example 2 with TimeRangeDocument

use of net.opengis.swe.x101.TimeRangeDocument in project arctic-sea by 52North.

the class SweCommonDecoderV101Test method should_decode_TimeRange.

@Test
public void should_decode_TimeRange() throws DecodingException {
    final TimeRangeDocument xbTimeRangeDoc = TimeRangeDocument.Factory.newInstance();
    TimeRange xbTimeRange = xbTimeRangeDoc.addNewTimeRange();
    final DateTime startDate = new DateTime(1970, 1, 1, 0, 0, DateTimeZone.UTC);
    final DateTime endDate = new DateTime(2013, 12, 31, 23, 59, DateTimeZone.UTC);
    final List<String> values = Lists.newArrayList(startDate.toString(), endDate.toString());
    xbTimeRange.setValue(values);
    final String iso8601Uom = "urn:ogc:def:unit:ISO:8601";
    xbTimeRange.addNewUom().setHref(iso8601Uom);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbTimeRange);
    assertThat(decodedObject, is(instanceOf(SweTimeRange.class)));
    final SweTimeRange sweTimeRange = (SweTimeRange) decodedObject;
    assertThat(sweTimeRange.isSetUom(), is(true));
    assertThat(sweTimeRange.getUom(), is(iso8601Uom));
    assertThat(sweTimeRange.isSetValue(), is(true));
    assertThat(sweTimeRange.getValue().getRangeStart(), is(startDate));
    assertThat(sweTimeRange.getValue().getRangeEnd(), is(endDate));
}
Also used : SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) TimeRange(net.opengis.swe.x101.TimeRangeDocument.TimeRange) TimeRangeDocument(net.opengis.swe.x101.TimeRangeDocument) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 3 with TimeRangeDocument

use of net.opengis.swe.x101.TimeRangeDocument in project arctic-sea by 52North.

the class SweCommonDecoderV20Test method should_decode_TimeRange.

@Test
public void should_decode_TimeRange() throws DecodingException {
    final TimeRangeDocument xbTimeRangeDoc = TimeRangeDocument.Factory.newInstance();
    TimeRangeType xbTimeRange = xbTimeRangeDoc.addNewTimeRange();
    final DateTime startDate = new DateTime(1970, 1, 1, 0, 0, DateTimeZone.UTC);
    final DateTime endDate = new DateTime(2013, 12, 31, 23, 59, DateTimeZone.UTC);
    final List<String> values = Lists.newArrayList(startDate.toString(), endDate.toString());
    xbTimeRange.setValue(values);
    final String iso8601Uom = "urn:ogc:def:unit:ISO:8601";
    xbTimeRange.addNewUom().setHref(iso8601Uom);
    final Object decodedObject = new SweCommonDecoderV20().decode(xbTimeRange);
    assertThat(decodedObject, is(instanceOf(SweTimeRange.class)));
    final SweTimeRange sweTimeRange = (SweTimeRange) decodedObject;
    assertThat(sweTimeRange.isSetUom(), is(true));
    assertThat(sweTimeRange.getUom(), is(iso8601Uom));
    assertThat(sweTimeRange.isSetValue(), is(true));
    assertThat(sweTimeRange.getValue().getRangeStart(), is(startDate));
    assertThat(sweTimeRange.getValue().getRangeEnd(), is(endDate));
}
Also used : TimeRangeType(net.opengis.swe.x20.TimeRangeType) SweCommonDecoderV20(org.n52.svalbard.decode.SweCommonDecoderV20) TimeRangeDocument(net.opengis.swe.x20.TimeRangeDocument) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

TimeRangeDocument (net.opengis.swe.x20.TimeRangeDocument)2 TimeRangeType (net.opengis.swe.x20.TimeRangeType)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.Test)2 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)2 TimeRangeDocument (net.opengis.swe.x101.TimeRangeDocument)1 TimeRange (net.opengis.swe.x101.TimeRangeDocument.TimeRange)1 BooleanDocument (net.opengis.swe.x20.BooleanDocument)1 BooleanType (net.opengis.swe.x20.BooleanType)1 CategoryDocument (net.opengis.swe.x20.CategoryDocument)1 CategoryRangeDocument (net.opengis.swe.x20.CategoryRangeDocument)1 CategoryRangeType (net.opengis.swe.x20.CategoryRangeType)1 CategoryType (net.opengis.swe.x20.CategoryType)1 CountDocument (net.opengis.swe.x20.CountDocument)1 CountRangeDocument (net.opengis.swe.x20.CountRangeDocument)1 CountRangeType (net.opengis.swe.x20.CountRangeType)1 CountType (net.opengis.swe.x20.CountType)1 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)1 DataArrayType (net.opengis.swe.x20.DataArrayType)1 DataChoiceDocument (net.opengis.swe.x20.DataChoiceDocument)1