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);
}
}
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;
}
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()));
}
}
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()));
}
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++;
}
}
}
}
Aggregations