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