Search in sources :

Example 1 with TimeseriesMetadataOutput

use of org.n52.io.response.dataset.TimeseriesMetadataOutput 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);
    }
}
Also used : TimeseriesMetadataOutput(org.n52.io.response.dataset.TimeseriesMetadataOutput) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) ParameterOutput(org.n52.io.response.ParameterOutput) DateTime(org.joda.time.DateTime)

Example 2 with TimeseriesMetadataOutput

use of org.n52.io.response.dataset.TimeseriesMetadataOutput 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()));
    }
}
Also used : Entry(org.n52.oxf.TableType.Entry) TableType(org.n52.oxf.TableType) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) QuantityData(org.n52.io.response.dataset.quantity.QuantityData) DateTime(org.joda.time.DateTime)

Example 3 with TimeseriesMetadataOutput

use of org.n52.io.response.dataset.TimeseriesMetadataOutput in project series-rest-api by 52North.

the class PDFReportGenerator method createValueTableHeader.

private String createValueTableHeader(TimeseriesMetadataOutput metadata) {
    SeriesParameters parameters = metadata.getSeriesParameters();
    String phenomenon = parameters.getPhenomenon().getLabel();
    return phenomenon + " (" + metadata.getUom() + ")";
}
Also used : SeriesParameters(org.n52.io.response.dataset.SeriesParameters)

Example 4 with TimeseriesMetadataOutput

use of org.n52.io.response.dataset.TimeseriesMetadataOutput in project series-rest-api by 52North.

the class TimeseriesMetadataController method addRenderingHints.

// stay backwards compatible
@SuppressWarnings("deprecation")
private TimeseriesMetadataOutput addRenderingHints(TimeseriesMetadataOutput output, IoParameters parameters) {
    final String valueName = TimeseriesMetadataOutput.RENDERING_HINTS;
    Predicate<MetadataExtension<?>> filter = RenderingHintsExtension.class::isInstance;
    Optional<Map<String, Object>> extras = getExtras(output, parameters, filter);
    extras.ifPresent(it -> {
        StyleProperties value = (StyleProperties) it.get(valueName);
        output.setValue(valueName, value, parameters, output::setRenderingHints);
    });
    return output;
}
Also used : StyleProperties(org.n52.io.request.StyleProperties) MetadataExtension(org.n52.io.response.extension.MetadataExtension) MultiValueMap(org.springframework.util.MultiValueMap) Map(java.util.Map)

Example 5 with TimeseriesMetadataOutput

use of org.n52.io.response.dataset.TimeseriesMetadataOutput in project series-rest-api by 52North.

the class CsvIoHandler method getPlatformLabel.

protected String getPlatformLabel(DatasetOutput<T> metadata) {
    DatasetParameters parameters = metadata.getDatasetParameters(true);
    ParameterOutput platform = parameters.getPlatform();
    return platform == null ? getLabel(((TimeseriesMetadataOutput) metadata).getStation()) : platform.getLabel();
}
Also used : TimeseriesMetadataOutput(org.n52.io.response.dataset.TimeseriesMetadataOutput) DatasetParameters(org.n52.io.response.dataset.DatasetParameters) ParameterOutput(org.n52.io.response.ParameterOutput)

Aggregations

DateTime (org.joda.time.DateTime)3 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)3 ParameterOutput (org.n52.io.response.ParameterOutput)2 DatasetParameters (org.n52.io.response.dataset.DatasetParameters)2 TimeseriesMetadataOutput (org.n52.io.response.dataset.TimeseriesMetadataOutput)2 TableType (org.n52.oxf.TableType)2 Entry (org.n52.oxf.TableType.Entry)2 BigDecimal (java.math.BigDecimal)1 Map (java.util.Map)1 StyleProperties (org.n52.io.request.StyleProperties)1 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)1 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)1 MetadataExtension (org.n52.io.response.extension.MetadataExtension)1 MultiValueMap (org.springframework.util.MultiValueMap)1