Search in sources :

Example 11 with SweQuantityRange

use of org.n52.shetland.ogc.swe.simpleType.SweQuantityRange in project arctic-sea by 52North.

the class SweCommonDecoderV101Test method should_decode_QuantityRange.

@Test
public void should_decode_QuantityRange() throws DecodingException {
    final QuantityRangeDocument xbQuantityRange = QuantityRangeDocument.Factory.newInstance();
    final ArrayList<BigDecimal> values = Lists.newArrayList(BigDecimal.valueOf(1.0), BigDecimal.valueOf(2.0));
    final QuantityRange xbQuantityRangeType = xbQuantityRange.addNewQuantityRange();
    xbQuantityRangeType.setValue(values);
    final String definition = "definition";
    xbQuantityRangeType.setDefinition(definition);
    final String axisId = "axis-id";
    xbQuantityRangeType.setAxisID(axisId);
    final String description = "description";
    xbQuantityRangeType.addNewDescription().setStringValue(description);
    final UomPropertyType xbUom = xbQuantityRangeType.addNewUom();
    final String uomCode = "uom-code";
    xbUom.setCode(uomCode);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbQuantityRange);
    assertThat(decodedObject, is(instanceOf(SweQuantityRange.class)));
    final SweQuantityRange sweQuantityRange = (SweQuantityRange) decodedObject;
    assertThat(sweQuantityRange.isSetDefinition(), is(true));
    assertThat(sweQuantityRange.getDefinition(), is(definition));
    assertThat(sweQuantityRange.isSetUom(), is(true));
    assertThat(sweQuantityRange.getUom(), is(uomCode));
    assertThat(sweQuantityRange.isSetAxisID(), is(true));
    assertThat(sweQuantityRange.getAxisID(), is(axisId));
    assertThat(sweQuantityRange.isSetDescription(), is(true));
    assertThat(sweQuantityRange.getDescription(), is(description));
    assertThat(sweQuantityRange.isSetValue(), is(true));
    assertThat(sweQuantityRange.getValue().getRangeStart(), is(values.get(0)));
    assertThat(sweQuantityRange.getValue().getRangeEnd(), is(values.get(1)));
}
Also used : UomPropertyType(net.opengis.swe.x101.UomPropertyType) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) QuantityRangeDocument(net.opengis.swe.x101.QuantityRangeDocument) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) QuantityRange(net.opengis.swe.x101.QuantityRangeDocument.QuantityRange) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 12 with SweQuantityRange

use of org.n52.shetland.ogc.swe.simpleType.SweQuantityRange in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createField.

private DataComponentPropertyType createField(SweField sweField) throws EncodingException {
    SweAbstractDataComponent sosElement = sweField.getElement();
    DataComponentPropertyType xbField = DataComponentPropertyType.Factory.newInstance(getXmlOptions());
    if (sweField.isSetName()) {
        xbField.setName(sweField.getName().getValue());
    }
    if (sosElement instanceof SweBoolean) {
        xbField.addNewBoolean().set(createSimpleType((SweBoolean) sosElement));
    } else if (sosElement instanceof SweCategory) {
        xbField.addNewCategory().set(createSimpleType((SweCategory) sosElement));
    } else if (sosElement instanceof SweCount) {
        xbField.addNewCount().set(createSimpleType((SweCount) sosElement));
    } else if (sosElement instanceof SweCountRange) {
        xbField.addNewCount().set(createSimpleType((SweCountRange) sosElement));
    } else if (sosElement instanceof SweQuantity) {
        xbField.addNewQuantity().set(createSimpleType((SweQuantity) sosElement));
    } else if (sosElement instanceof SweQuantityRange) {
        xbField.addNewQuantity().set(createSimpleType((SweQuantityRange) sosElement));
    } else if (sosElement instanceof SweText) {
        xbField.addNewText().set(createSimpleType((SweText) sosElement));
    } else if (sosElement instanceof SweTimeRange) {
        xbField.addNewTimeRange().set(createSimpleType((SweTimeRange) sosElement));
    } else if (sosElement instanceof SweTime) {
        xbField.addNewTime().set(createSimpleType((SweTime) sosElement));
    } else if (sosElement instanceof SweEnvelope) {
        EnvelopeType xbEnvelope = (EnvelopeType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_ENVELOPE_SWE_101, EnvelopeType.type);
        xbEnvelope.set(createEnvelope((SweEnvelope) sosElement));
    } else if (sosElement instanceof SweDataRecord) {
        DataRecordType xbEnvelope = (DataRecordType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
        xbEnvelope.set(createDataRecord((SweDataRecord) sosElement));
    } else if (sosElement instanceof SweDataArray) {
        DataArrayType xbEnvelope = (DataArrayType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataArrayType.type);
        xbEnvelope.set(createDataArray((SweDataArray) sosElement).getDataArray1());
    } else {
        throw new EncodingException("The element type '%s' of the received '%s' is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
    }
    return xbField;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) DataRecordType(net.opengis.swe.x101.DataRecordType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) EnvelopeType(net.opengis.swe.x101.EnvelopeType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) DataArrayType(net.opengis.swe.x101.DataArrayType)

Example 13 with SweQuantityRange

use of org.n52.shetland.ogc.swe.simpleType.SweQuantityRange in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createSimpleType.

private AbstractDataComponentType createSimpleType(SweAbstractSimpleType<?> sosSimpleType, EncodingContext additionalValues) throws EncodingException {
    AbstractDataComponentType abstractDataComponentType = null;
    if (sosSimpleType instanceof SweBoolean) {
        abstractDataComponentType = createBoolean((SweBoolean) sosSimpleType);
    } else if (sosSimpleType instanceof SweCategory) {
        abstractDataComponentType = createCategory((SweCategory) sosSimpleType);
    } else if (sosSimpleType instanceof SweCount) {
        abstractDataComponentType = createCount((SweCount) sosSimpleType);
    } else if (sosSimpleType instanceof SweCountRange) {
        abstractDataComponentType = createCountRange((SweCountRange) sosSimpleType);
    } else if (sosSimpleType instanceof SweObservableProperty) {
        abstractDataComponentType = createObservableProperty((SweObservableProperty) sosSimpleType);
    } else if (sosSimpleType instanceof SweQuantity) {
        abstractDataComponentType = createQuantity((SweQuantity) sosSimpleType);
    } else if (sosSimpleType instanceof SweQuantityRange) {
        abstractDataComponentType = createQuantityRange((SweQuantityRange) sosSimpleType);
    } else if (sosSimpleType instanceof SweText) {
        abstractDataComponentType = createText((SweText) sosSimpleType);
    } else if (sosSimpleType instanceof SweTimeRange) {
        abstractDataComponentType = createTimeRange((SweTimeRange) sosSimpleType);
    } else if (sosSimpleType instanceof SweTime) {
        abstractDataComponentType = createTime((SweTime) sosSimpleType);
    } else {
        throw new NotYetSupportedEncodingException(SweAbstractSimpleType.class.getSimpleName(), sosSimpleType);
    }
    addAbstractDataComponentValues(abstractDataComponentType, sosSimpleType);
    return abstractDataComponentType;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty)

Aggregations

SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)11 BigDecimal (java.math.BigDecimal)5 Test (org.junit.Test)5 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)5 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)4 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 XmlObject (org.apache.xmlbeans.XmlObject)3 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)3 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)3 DataRecordType (net.opengis.swe.x101.DataRecordType)2 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)2 RangeValue (org.n52.shetland.ogc.swe.RangeValue)2 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)2 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)2 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)2 SweField (org.n52.shetland.ogc.swe.SweField)2 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)2 SweCountRange (org.n52.shetland.ogc.swe.simpleType.SweCountRange)2 SweQuality (org.n52.shetland.ogc.swe.simpleType.SweQuality)2