Search in sources :

Example 1 with TimeseriesMetadata

use of org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata in project arctic-sea by 52North.

the class WmlTVPEncoderv20 method addTimeseriesMetadata.

private void addTimeseriesMetadata(MeasurementTimeseriesType mtt, String gmlId, TimeseriesMetadata timeseriesMetadata) {
    MeasurementTimeseriesMetadataType mtmt = (MeasurementTimeseriesMetadataType) mtt.addNewMetadata().addNewTimeseriesMetadata().substitute(WaterMLConstants.QN_MEASUREMENT_TIMESERIES_METADATA, MeasurementTimeseriesMetadataType.type);
    createMeasurementTimeseriesMetadataType(mtmt, gmlId);
    if (timeseriesMetadata != null && timeseriesMetadata.getClass().isAssignableFrom(MeasurementTimeseriesMetadata.class)) {
        mtmt.setCumulative(((MeasurementTimeseriesMetadata) timeseriesMetadata).isCumulative());
    }
}
Also used : MeasurementTimeseriesMetadataType(net.opengis.waterml.x20.MeasurementTimeseriesMetadataType) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata)

Example 2 with TimeseriesMetadata

use of org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata in project arctic-sea by 52North.

the class WmlTVPEncoderv20 method createMeasurementTimeseries.

/**
 * Create a XML MeasurementTimeseries object from SOS observation for
 * om:result
 *
 * @param sosObservation
 *            SOS observation
 *
 * @return XML MeasurementTimeseries object
 *
 * @throws CodedException
 *             if the encoding fails
 */
private XmlObject createMeasurementTimeseries(OmObservation sosObservation) throws OwsExceptionReport {
    MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
    MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
    measurementTimeseries.setId(TIMESERIES_ID_PREFIX + sosObservation.getObservationID());
    // Default value
    TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
    if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getValue().getValue().getClass().isAssignableFrom(TVPValue.class) && sosObservation.getObservationConstellation().isSetMetadata() && sosObservation.getObservationConstellation().getMetadata().isSetTimeseriesMetadata()) {
        timeseriesMetadata = sosObservation.getObservationConstellation().getMetadata().getTimeseriesmetadata();
    }
    addTimeseriesMetadata(measurementTimeseries, sosObservation.getPhenomenonTime().getGmlId(), timeseriesMetadata);
    TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
    TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
    // Default value
    InterpolationType interpolationType = InterpolationType.Continuous;
    if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getObservationConstellation().isSetDefaultPointMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        interpolationType = sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
    }
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
    String unit = addValues(measurementTimeseries, sosObservation.getValue());
    // set uom
    if (unit != null && !unit.isEmpty()) {
        defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
    } else {
        OmObservableProperty observableProperty = (OmObservableProperty) sosObservation.getObservationConstellation().getObservableProperty();
        if (observableProperty.isSetUnit()) {
            defaultTVPMeasurementMetadata.addNewUom().setCode(observableProperty.getUnit());
        }
    }
    xbMetaComponent.set(xbDefMeasureMetaComponent);
    return measurementTimeseriesDoc;
}
Also used : TimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) MeasurementTimeseriesType(net.opengis.waterml.x20.MeasurementTimeseriesType) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) TVPMeasurementMetadataType(net.opengis.waterml.x20.TVPMeasurementMetadataType) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType) MeasurementTimeseriesDocument(net.opengis.waterml.x20.MeasurementTimeseriesDocument) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 3 with TimeseriesMetadata

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

the class MultipleChartsRenderer method writeDataToChart.

@Override
public void writeDataToChart(DataCollection<Data<QuantityValue>> data) {
    Map<String, Data<QuantityValue>> 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 = getDatasetStyleFor(timeseriesId);
        Data<QuantityValue> 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.
                 */
            DatasetMetadata<QuantityValue> metadata = timeseriesData.getMetadata();
            Map<String, Data<QuantityValue>> referenceValues = metadata.getReferenceValues();
            for (Entry<String, Data<QuantityValue>> referencedTimeseries : referenceValues.entrySet()) {
                String referenceTimeseriesId = referencedTimeseries.getKey();
                ReferenceValueOutput<?> referenceOutput = getReferenceValue(referenceTimeseriesId, timeseriesMetadata);
                String referenceChartId = createChartId(timeseriesMetadata, referenceOutput.getLabel());
                Data<QuantityValue> 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 : Data(org.n52.io.response.dataset.Data) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) StyleProperties(org.n52.io.request.StyleProperties)

Example 4 with TimeseriesMetadata

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

the class ChartIoHandler method createRangeLabel.

protected String createRangeLabel(DatasetOutput timeseriesMetadata) {
    SeriesParameters parameters = timeseriesMetadata.getSeriesParameters();
    ParameterOutput phenomenon = parameters.getPhenomenon();
    StringBuilder uom = new StringBuilder();
    uom.append(phenomenon.getLabel());
    String uomLabel = timeseriesMetadata.getUom();
    if (uomLabel != null && !uomLabel.isEmpty()) {
        uom.append(" [").append(uomLabel).append("]");
    }
    return uom.toString();
}
Also used : SeriesParameters(org.n52.io.response.dataset.SeriesParameters) ParameterOutput(org.n52.io.response.ParameterOutput)

Example 5 with TimeseriesMetadata

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

MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata)3 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)2 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)2 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)2 StyleProperties (org.n52.io.request.StyleProperties)2 TimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata)2 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)2 MeasurementTimeseriesMetadataType (net.opengis.waterml.x20.MeasurementTimeseriesMetadataType)1 ParameterOutput (org.n52.io.response.ParameterOutput)1 Data (org.n52.io.response.dataset.Data)1 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)1 ReferenceValueOutput (org.n52.io.response.dataset.ReferenceValueOutput)1 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)1 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)1 QuantityDatasetMetadata (org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)1 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)1