Search in sources :

Example 1 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata 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 Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.

the class FlotFormatter method createFlotSeries.

private FlotData createFlotSeries(QuantityData seriesToFormat) {
    FlotData flotSeries = new FlotData();
    flotSeries.setValues(formatSeries(seriesToFormat));
    QuantityDatasetMetadata metadata = seriesToFormat.getMetadata();
    if (metadata != null) {
        Map<String, QuantityData> referenceValues = metadata.getReferenceValues();
        for (String referenceValueId : referenceValues.keySet()) {
            QuantityData referenceValueData = metadata.getReferenceValues().get(referenceValueId);
            flotSeries.addReferenceValues(referenceValueId, formatSeries(referenceValueData));
        }
    }
    return flotSeries;
}
Also used : QuantityData(org.n52.io.response.dataset.quantity.QuantityData) QuantityDatasetMetadata(org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)

Example 3 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.

the class PDFReportGenerator method generateTimeseriesMetadata.

private void generateTimeseriesMetadata() {
    for (DatasetOutput metadata : getSeriesMetadatas()) {
        TimeSeries timeseries = addTimeseries(metadata);
        // addDataTable(timeseries, metadata, data);
        addMetadata(timeseries, metadata);
    }
}
Also used : TimeSeries(org.n52.oxf.DocumentStructureType.TimeSeries) DatasetOutput(org.n52.io.response.dataset.DatasetOutput)

Example 4 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.

the class PDFReportGenerator method addTimeseries.

private TimeSeries addTimeseries(DatasetOutput metadata) {
    DocumentStructureType report = document.getDocumentStructure();
    TimeSeries timeseries = report.addNewTimeSeries();
    SeriesParameters parameters = metadata.getSeriesParameters();
    timeseries.setFeatureOfInterestID(parameters.getFeature().getLabel());
    timeseries.setPhenomenID(parameters.getPhenomenon().getLabel());
    timeseries.setProcedureID(parameters.getProcedure().getLabel());
    return timeseries;
}
Also used : TimeSeries(org.n52.oxf.DocumentStructureType.TimeSeries) SeriesParameters(org.n52.io.response.dataset.SeriesParameters) DocumentStructureType(org.n52.oxf.DocumentStructureType)

Example 5 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata 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)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)5 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)5 IoParameters (org.n52.io.request.IoParameters)4 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)4 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)4 Test (org.junit.Test)3 QuantityDatasetMetadata (org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)3 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)3 Strings (com.google.common.base.Strings)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 XmlException (org.apache.xmlbeans.XmlException)2 DateTime (org.joda.time.DateTime)2 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)2 ParameterOutput (org.n52.io.response.ParameterOutput)2 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)2 LocalizedString (org.n52.janmayen.i18n.LocalizedString)2