Search in sources :

Example 6 with TimeSeries

use of org.n52.oxf.DocumentStructureType.TimeSeries 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 7 with TimeSeries

use of org.n52.oxf.DocumentStructureType.TimeSeries 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 8 with TimeSeries

use of org.n52.oxf.DocumentStructureType.TimeSeries 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 9 with TimeSeries

use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.

the class ChartRendererTest method shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive.

@Test
public void shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive() {
    QuantityDatasetOutput metadata = new QuantityDatasetOutput();
    SeriesParameters parameters = new SeriesParameters();
    parameters.setCategory(createParameter(new CategoryOutput(), "cat_1", "category"));
    parameters.setFeature(createParameter(new FeatureOutput(), "feat_1", "feature"));
    parameters.setOffering(createParameter(new OfferingOutput(), "off_1", "offering"));
    parameters.setPhenomenon(createParameter(new PhenomenonOutput(), "phen_1", "phenomenon"));
    parameters.setProcedure(createParameter(new ProcedureOutput(), "proc_1", "procedure"));
    parameters.setService(createParameter(new ServiceOutput(), "ser_1", "service"));
    metadata.setSeriesParameters(parameters);
    metadata.setId("timeseries");
    metadata.setUom("");
    PlatformOutput platformOutput = new PlatformOutput(PlatformType.STATIONARY_INSITU);
    platformOutput.setId("sta_1");
    platformOutput.setLabel("station");
    parameters.setPlatform(platformOutput);
    // build expected title
    StringBuilder expected = new StringBuilder();
    expected.append(parameters.getPlatform().getLabel());
    expected.append(" ").append(parameters.getPhenomenon().getLabel());
    expected.append(" ").append(parameters.getProcedure().getLabel());
    // expected.append(" ").append(parameters.getCategory().getLabel());
    expected.append(" (4 opted-out)");
    expected.append(" ").append(parameters.getOffering().getLabel());
    expected.append(" ").append(parameters.getFeature().getLabel());
    expected.append(" ").append(parameters.getService().getLabel());
    expected.append(" ").append(metadata.getUom());
    IoParameters ioConfig = createDefaults().extendWith("rendering_trigger", "prerendering");
    IoStyleContext context = IoStyleContext.createContextForSingleSeries(metadata, ioConfig);
    MyChartRenderer chartRenderer = new MyChartRenderer(context);
    // String template = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s";
    String template = "%1$s %2$s %3$s (4 opted-out) %5$s %6$s %7$s %8$s";
    String actual = chartRenderer.formatTitle(metadata, template);
    assertThat(actual, is(expected.toString()));
}
Also used : OfferingOutput(org.n52.io.response.OfferingOutput) ServiceOutput(org.n52.io.response.ServiceOutput) FeatureOutput(org.n52.io.response.FeatureOutput) IoStyleContext(org.n52.io.IoStyleContext) IoParameters(org.n52.io.request.IoParameters) PlatformOutput(org.n52.io.response.PlatformOutput) CategoryOutput(org.n52.io.response.CategoryOutput) ProcedureOutput(org.n52.io.response.ProcedureOutput) SeriesParameters(org.n52.io.response.dataset.SeriesParameters) QuantityDatasetOutput(org.n52.io.response.dataset.quantity.QuantityDatasetOutput) PhenomenonOutput(org.n52.io.response.PhenomenonOutput) Test(org.junit.Test)

Example 10 with TimeSeries

use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.

the class MultipleChartsRenderer method writeDataToChart.

@Override
public void writeDataToChart(DataCollection<QuantityData> data) {
    Map<String, QuantityData> allTimeseries = data.getAllSeries();
    List<? extends DatasetOutput> timeseriesMetadatas = getMetadataOutputs();
    int rendererCount = timeseriesMetadatas.size();
    for (int rendererIndex = 0; rendererIndex < timeseriesMetadatas.size(); rendererIndex++) {
        /*
             * For each index put data and its renderer configured to a particular style.
             *
             * As each timeseries may define its custom styling and different chart types we have to loop over
             * all timeseries to configure chart rendering.
             */
        DatasetOutput timeseriesMetadata = timeseriesMetadatas.get(rendererIndex);
        String timeseriesId = timeseriesMetadata.getId();
        StyleProperties style = getTimeseriesStyleFor(timeseriesId);
        QuantityData timeseriesData = allTimeseries.get(timeseriesId);
        String chartId = createChartId(timeseriesMetadata);
        ChartIndexConfiguration configuration = new ChartIndexConfiguration(chartId, rendererIndex);
        configuration.setData(timeseriesData, timeseriesMetadata, style);
        configuration.setRenderer(createRenderer(style));
        if (timeseriesData.hasReferenceValues()) {
            int referenceIndex = rendererCount;
            /*
                 * Configure timeseries reference value renderers with the same metadata and add it at the end
                 * of the plot's renderer list.
                 */
            QuantityDatasetMetadata metadata = timeseriesData.getMetadata();
            Map<String, QuantityData> referenceValues = metadata.getReferenceValues();
            for (Entry<String, QuantityData> referencedTimeseries : referenceValues.entrySet()) {
                String referenceTimeseriesId = referencedTimeseries.getKey();
                ReferenceValueOutput referenceOutput = getReferenceValue(referenceTimeseriesId, timeseriesMetadata);
                String referenceChartId = createChartId(timeseriesMetadata, referenceOutput.getLabel());
                QuantityData referenceData = referenceValues.get(referenceTimeseriesId);
                ChartIndexConfiguration referenceConfiguration = new ChartIndexConfiguration(referenceChartId, referenceIndex);
                StyleProperties referenceStyle = getTimeseriesStyleFor(timeseriesId, referenceTimeseriesId);
                referenceConfiguration.setReferenceData(referenceData, timeseriesMetadata, referenceStyle);
                referenceConfiguration.setRenderer(createRenderer(referenceStyle));
                referenceIndex++;
            }
        }
    }
}
Also used : ReferenceValueOutput(org.n52.io.response.dataset.ReferenceValueOutput) DatasetOutput(org.n52.io.response.dataset.DatasetOutput) StyleProperties(org.n52.io.request.StyleProperties) QuantityData(org.n52.io.response.dataset.quantity.QuantityData) QuantityDatasetMetadata(org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)

Aggregations

QuantityData (org.n52.io.response.dataset.quantity.QuantityData)7 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)5 ArrayList (java.util.ArrayList)3 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)3 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 IoParameters (org.n52.io.request.IoParameters)2 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)2 TvpDataCollection (org.n52.io.series.TvpDataCollection)2 TimeSeries (org.n52.oxf.DocumentStructureType.TimeSeries)2 Line2D (java.awt.geom.Line2D)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 I18N (org.n52.io.I18N)1 IoStyleContext (org.n52.io.IoStyleContext)1 FilterResolver (org.n52.io.request.FilterResolver)1 StyleProperties (org.n52.io.request.StyleProperties)1 CategoryOutput (org.n52.io.response.CategoryOutput)1 FeatureOutput (org.n52.io.response.FeatureOutput)1