Search in sources :

Example 1 with SweCountRange

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

the class FieldDecoderTest method testCountRangeWithValue.

@Test
public void testCountRangeWithValue() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.COUNT_RANGE_TYPE);
    json.putArray(JSONConstants.VALUE).add(COUNT_VALUE_START).add(COUNT_VALUE_END);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweCountRange.class)));
    SweCountRange swe = (SweCountRange) field.getElement();
    assertThat(swe.getValue(), is(notNullValue()));
    errors.checkThat(swe.getValue().getRangeStart(), is(COUNT_VALUE_START));
    errors.checkThat(swe.getValue().getRangeEnd(), is(COUNT_VALUE_END));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) Test(org.junit.Test)

Example 2 with SweCountRange

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

the class FieldDecoderTest method testCountRange.

@Test
public void testCountRange() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.COUNT_RANGE_TYPE);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweCountRange.class)));
    SweCountRange swe = (SweCountRange) field.getElement();
    assertThat(swe.getValue(), is(nullValue()));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) Test(org.junit.Test)

Example 3 with SweCountRange

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

the class FieldEncoder method encodeSweCountRangeField.

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

Example 4 with SweCountRange

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

the class FieldDecoder method decodeCountRange.

protected SweAbstractDataComponent decodeCountRange(JsonNode node) {
    SweCountRange swe = new SweCountRange();
    if (node.hasNonNull(JSONConstants.VALUE)) {
        int start = node.path(JSONConstants.VALUE).path(0).intValue();
        int end = node.path(JSONConstants.VALUE).path(1).intValue();
        swe.setValue(new RangeValue<Integer>(start, end));
    }
    return swe;
}
Also used : SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange)

Example 5 with SweCountRange

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

the class SweCommonDecoderV101 method parseCountRange.

private SweCountRange parseCountRange(CountRange xbCountRange) throws DecodingException {
    SweCountRange sosCountRange = new SweCountRange();
    // }
    if (xbCountRange.getQualityArray() != null) {
        sosCountRange.setQuality(parseQuality(xbCountRange.getQualityArray()));
    }
    // }
    if (xbCountRange.isSetDefinition()) {
        sosCountRange.setDefinition(xbCountRange.getDefinition());
    }
    if (xbCountRange.isSetDescription()) {
        sosCountRange.setDescription(xbCountRange.getDescription().getStringValue());
    }
    if (xbCountRange.isSetValue()) {
        List<?> value = xbCountRange.getValue();
        Integer rangeStart = Integer.parseInt(value.get(0).toString());
        Integer rangeEnd = Integer.parseInt(value.get(1).toString());
        sosCountRange.setValue(new RangeValue<>(rangeStart, rangeEnd));
    }
    return sosCountRange;
}
Also used : SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange)

Aggregations

SweCountRange (org.n52.shetland.ogc.swe.simpleType.SweCountRange)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Test (org.junit.Test)2 SweField (org.n52.shetland.ogc.swe.SweField)2 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)2 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)2 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)2 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)2 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)2 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)2 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)2 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)2 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 AbstractDataComponentType (net.opengis.swe.x101.AbstractDataComponentType)1 DataArrayType (net.opengis.swe.x101.DataArrayType)1 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)1 DataRecordType (net.opengis.swe.x101.DataRecordType)1 EnvelopeType (net.opengis.swe.x101.EnvelopeType)1 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)1