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));
}
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()));
}
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;
}
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;
}
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;
}
Aggregations