Search in sources :

Example 56 with SweField

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

the class FieldDecoderTest method testQuantityWithValue.

@Test
public void testQuantityWithValue() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_TYPE).put(JSONConstants.UOM, UOM).put(JSONConstants.VALUE, QUANTITY_VALUE_START);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweQuantity.class)));
    SweQuantity swe = (SweQuantity) field.getElement();
    errors.checkThat(swe.getValue().doubleValue(), is(QUANTITY_VALUE_START));
    errors.checkThat(swe.getUom(), is(UOM));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Example 57 with SweField

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

the class FieldEncoder method encodeSweTextField.

private ObjectNode encodeSweTextField(SweField field) {
    ObjectNode jfield = createField(field);
    jfield.put(JSONConstants.TYPE, JSONConstants.TEXT_TYPE);
    SweText sweText = (SweText) field.getElement();
    if (sweText.isSetValue()) {
        jfield.put(JSONConstants.VALUE, sweText.getValue());
    }
    return jfield;
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 58 with SweField

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

the class FieldEncoder method encodeSweQuantityRangeField.

private ObjectNode encodeSweQuantityRangeField(SweField field) {
    ObjectNode jfield = createField(field);
    jfield.put(JSONConstants.TYPE, JSONConstants.QUANTITY_RANGE_TYPE);
    SweQuantityRange sweQuantityRange = (SweQuantityRange) field.getElement();
    jfield.put(JSONConstants.UOM, sweQuantityRange.getUom());
    if (sweQuantityRange.isSetValue()) {
        ArrayNode av = jfield.putArray(JSONConstants.VALUE);
        av.add(sweQuantityRange.getValue().getRangeStart());
        av.add(sweQuantityRange.getValue().getRangeEnd());
    }
    return jfield;
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 59 with SweField

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

the class FieldEncoder method encodeSweObservableProperyField.

private ObjectNode encodeSweObservableProperyField(SweField field) {
    ObjectNode jfield = createField(field);
    jfield.put(JSONConstants.TYPE, JSONConstants.OBSERVABLE_PROPERTY_TYPE);
    SweObservableProperty sweObservableProperty = (SweObservableProperty) field.getElement();
    if (sweObservableProperty.isSetValue()) {
        jfield.put(JSONConstants.VALUE, sweObservableProperty.getValue());
    }
    return jfield;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty)

Example 60 with SweField

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

the class FieldEncoder method encodeSweTimeRangeField.

private ObjectNode encodeSweTimeRangeField(SweField field) {
    ObjectNode jfield = createField(field);
    jfield.put(JSONConstants.TYPE, JSONConstants.TIME_RANGE_TYPE);
    SweTimeRange sweTimeRange = (SweTimeRange) field.getElement();
    jfield.put(JSONConstants.UOM, sweTimeRange.getUom());
    if (sweTimeRange.isSetValue()) {
        ArrayNode av = jfield.putArray(JSONConstants.VALUE);
        av.add(DateTimeHelper.formatDateTime2IsoString(sweTimeRange.getValue().getRangeStart()));
        av.add(DateTimeHelper.formatDateTime2IsoString(sweTimeRange.getValue().getRangeEnd()));
    }
    return jfield;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange)

Aggregations

SweField (org.n52.shetland.ogc.swe.SweField)59 Test (org.junit.Test)42 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)34 XmlObject (org.apache.xmlbeans.XmlObject)20 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)19 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)19 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)12 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)12 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)11 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)11 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)11 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)10 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)10 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)9 DataRecordType (net.opengis.swe.x101.DataRecordType)9 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)9 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)9 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)8 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)7 DateTime (org.joda.time.DateTime)4