use of org.n52.shetland.ogc.UoM in project series-rest-api by 52North.
the class QuantityCsvIoHandler method writeData.
private void writeData(DatasetOutput metadata, QuantityData series, OutputStream stream) throws IOException {
String station = null;
ParameterOutput platform = metadata.getSeriesParameters().getPlatform();
if (platform == null) {
TimeseriesMetadataOutput output = (TimeseriesMetadataOutput) metadata;
station = output.getStation().getLabel();
} else {
station = platform.getLabel();
}
String phenomenon = metadata.getSeriesParameters().getPhenomenon().getLabel();
String uom = metadata.getUom();
for (QuantityValue timeseriesValue : series.getValues()) {
String[] values = new String[getHeader().length];
values[0] = station;
values[1] = phenomenon;
values[2] = uom;
Long timestart = timeseriesValue.getTimestart();
Long timeend = timeseriesValue.getTimestamp();
values[3] = timestart != null ? new DateTime(timestart).toString() : null;
values[4] = new DateTime(timeend).toString();
values[5] = numberformat.format(timeseriesValue.getValue());
writeCsvLine(csvEncode(values), stream);
}
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class FieldDecoderTest method timeRange.
@Test
public void timeRange() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_RANGE_TYPE).put(JSONConstants.UOM, UOM);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweTimeRange.class)));
SweTimeRange swe = (SweTimeRange) field.getElement();
errors.checkThat(swe.getUom(), is(UOM));
errors.checkThat(swe.getValue(), is(nullValue()));
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class FieldDecoderTest method time.
@Test
public void time() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_TYPE).put(JSONConstants.UOM, UOM);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweTime.class)));
SweTime swe = (SweTime) field.getElement();
errors.checkThat(swe.getValue(), is(nullValue()));
errors.checkThat(swe.getUom(), is(UOM));
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class FieldDecoderTest method testQuantity.
@Test
public void testQuantity() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_TYPE).put(JSONConstants.UOM, UOM);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweQuantity.class)));
SweQuantity swe = (SweQuantity) field.getElement();
errors.checkThat(swe.getUom(), is(UOM));
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class FieldDecoderTest method timeWithValue.
@Test
public void timeWithValue() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_TYPE).put(JSONConstants.UOM, UOM).put(JSONConstants.VALUE, TIME_START);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweTime.class)));
SweTime swe = (SweTime) field.getElement();
errors.checkThat(swe.getValue(), is(timeStart));
errors.checkThat(swe.getUom(), is(UOM));
}
Aggregations