use of org.n52.shetland.ogc.om.series.wml.Metadata 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++;
}
}
}
}
use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.
the class MultipleChartsRenderer method createChartId.
private String createChartId(DatasetOutput metadata, String referenceId) {
ParameterOutput feature = metadata.getSeriesParameters().getFeature();
StringBuilder timeseriesLabel = new StringBuilder();
timeseriesLabel.append(feature.getLabel());
if (referenceId != null) {
timeseriesLabel.append(", ").append(referenceId);
}
timeseriesLabel.append(" (").append(createRangeLabel(metadata)).append(")");
return timeseriesLabel.toString();
}
use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.
the class HighchartFormatter method format.
@Override
public HighchartDataCollection format(DataCollection<QuantityData> toFormat) {
HighchartDataCollection dataCollection = new HighchartDataCollection();
for (String timeseriesId : toFormat.getAllSeries().keySet()) {
QuantityData seriesToFormat = toFormat.getSeries(timeseriesId);
HighchartData series = createHighchartSeries(timeseriesId, seriesToFormat);
dataCollection.addNewSeries(timeseriesId, series);
QuantityDatasetMetadata metadata = seriesToFormat.getMetadata();
if (metadata != null) {
Map<String, QuantityData> referenceValues = metadata.getReferenceValues();
for (String referenceValueId : referenceValues.keySet()) {
QuantityData timeseriesData = metadata.getReferenceValues().get(referenceValueId);
HighchartData referenceSeries = createHighchartSeries(referenceValueId, timeseriesData);
dataCollection.addNewSeries(referenceValueId, referenceSeries);
}
}
}
return dataCollection;
}
use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.
the class ChartIoHandler method getTitleForSingle.
private String getTitleForSingle(RequestStyledParameterSet config, String template) {
String[] timeseries = config.getDatasets();
if (timeseries != null && timeseries.length > 0) {
String timeseriesId = timeseries[0];
DatasetOutput metadata = getTimeseriesMetadataOutput(timeseriesId);
if (metadata != null) {
return formatTitle(metadata, template);
}
}
return template;
}
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(DataCollection<QuantityData> data, OutputStream stream) throws IOException {
for (DatasetOutput metadata : seriesMetadatas) {
QuantityData series = data.getSeries(metadata.getId());
writeData(metadata, (QuantityData) series, stream);
}
}
Aggregations