use of org.n52.io.response.dataset.quantity.QuantityValue 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.io.response.dataset.quantity.QuantityValue in project series-rest-api by 52North.
the class FlotFormatter method formatSeries.
private List<Number[]> formatSeries(QuantityData timeseries) {
List<Number[]> series = new ArrayList<>();
for (QuantityValue currentValue : timeseries.getValues()) {
List<Number> list = new ArrayList<>();
list.add(currentValue.getTimestamp());
list.add(currentValue.getValue());
if (currentValue.isSetGeometry()) {
Coordinate coordinate = currentValue.getGeometry().getCoordinate();
list.add(coordinate.x);
list.add(coordinate.y);
if (!Double.isNaN(coordinate.z)) {
list.add(coordinate.z);
}
}
series.add(list.toArray(new Number[0]));
}
return series;
}
use of org.n52.io.response.dataset.quantity.QuantityValue in project series-rest-api by 52North.
the class PDFReportGenerator method addDataTable.
private void addDataTable(TimeSeries timeseries, TimeseriesMetadataOutput metadata, TvpDataCollection<QuantityData> dataCollection) {
TableType dataTable = timeseries.addNewTable();
// TODO add language context
dataTable.setLeftColHeader("Date");
dataTable.setRightColHeader(createValueTableHeader(metadata));
QuantityData data = dataCollection.getSeries(metadata.getId());
for (QuantityValue valueEntry : data.getValues()) {
Entry entry = dataTable.addNewEntry();
// TODO update TableType schema to allow start/end time
entry.setTime(new DateTime(valueEntry.getTimestamp()).toString());
entry.setValue(Double.toString(valueEntry.getValue()));
}
}
Aggregations