Search in sources :

Example 1 with MeasurementTimeseriesMetadata

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

the class TsmlTVPEncoderv10 method createMeasurementTimeseries.

private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws CodedException, EncodingException {
    TimeseriesTVPDocument measurementTimeseriesDoc = TimeseriesTVPDocument.Factory.newInstance();
    TimeseriesTVPType measurementTimeseries = measurementTimeseriesDoc.addNewTimeseriesTVP();
    ((AbstractGMLType) measurementTimeseries).setId(TIMESERIES_ID_PREFIX + observationValue.getObservationID());
    // Default value
    TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
    if (observationValue.isSetValue() && observationValue.isSetMetadata() && observationValue.getMetadata().isSetTimeseriesMetadata()) {
        timeseriesMetadata = observationValue.getMetadata().getTimeseriesmetadata();
    }
    addTimeseriesMetadata(measurementTimeseries, observationValue.getPhenomenonTime().getGmlId(), timeseriesMetadata);
    TimeseriesTVPType.DefaultPointMetadata xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    PointMetadataDocument xbDefMeasureMetaComponent = PointMetadataDocument.Factory.newInstance();
    PointMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewPointMetadata();
    // Default value
    InterpolationType interpolationType = InterpolationType.Continuous;
    if (observationValue.isSetValue() && observationValue.isSetDefaultPointMetadata() && observationValue.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        interpolationType = (InterpolationType) observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
    }
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
    xbDefMeasureMetaComponent.getPointMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
    String unit = addValues(measurementTimeseries, observationValue);
    // 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 : MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) TimeseriesMetadata(org.n52.shetland.ogc.om.series.TimeseriesMetadata) TimeseriesTVPDocument(net.opengis.tsml.x10.TimeseriesTVPDocument) AbstractGMLType(net.opengis.gml.x32.AbstractGMLType) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) PointMetadataType(net.opengis.tsml.x10.PointMetadataType) PointMetadataDocument(net.opengis.tsml.x10.PointMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType) TimeseriesTVPType(net.opengis.tsml.x10.TimeseriesTVPType)

Example 2 with MeasurementTimeseriesMetadata

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

the class TsmlTVPEncoderv10 method addTimeseriesMetadata.

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

Example 3 with MeasurementTimeseriesMetadata

use of org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata 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 EncodingException
 *
 * @throws CodedException
 *             if the encoding fails
 */
private XmlObject createMeasurementTimeseries(OmObservation sosObservation) throws OwsExceptionReport, EncodingException {
    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 = (InterpolationType) sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
    }
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
    // set aggregationDuration
    if (sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetAggregationDuration()) {
        GDurationBuilder gDurationBuilder = new GDurationBuilder(sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getAggregationDuration());
        xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().setAggregationDuration(gDurationBuilder.toGDuration());
    }
    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 : MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) TimeseriesMetadata(org.n52.shetland.ogc.om.series.TimeseriesMetadata) 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.MeasurementTimeseriesMetadata) TVPMeasurementMetadataType(net.opengis.waterml.x20.TVPMeasurementMetadataType) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType) GDurationBuilder(org.apache.xmlbeans.GDurationBuilder) MeasurementTimeseriesDocument(net.opengis.waterml.x20.MeasurementTimeseriesDocument) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 4 with MeasurementTimeseriesMetadata

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

Example 5 with MeasurementTimeseriesMetadata

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

the class TsmlTVPEncoderv10Test method shouldEncodeCumulativeProperty.

@Test
public void shouldEncodeCumulativeProperty() throws EncodingException {
    mv.setMetadata(new Metadata().setTimeseriesmetadata(new MeasurementTimeseriesMetadata().setCumulative(true)));
    XmlObject encodedElement = encoder.encode(mv);
    MatcherAssert.assertThat(((TimeseriesTVPDocument) encodedElement).getTimeseriesTVP().getMetadata().getTimeseriesMetadata().getCumulative(), Is.is(true));
}
Also used : TimeseriesTVPDocument(net.opengis.tsml.x10.TimeseriesTVPDocument) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) DefaultPointMetadata(org.n52.shetland.ogc.om.series.DefaultPointMetadata) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.tsml.DefaultTVPMeasurementMetadata) Metadata(org.n52.shetland.ogc.om.series.Metadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.jupiter.api.Test)

Aggregations

MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata)9 TimeseriesMetadata (org.n52.shetland.ogc.om.series.TimeseriesMetadata)4 TimeseriesTVPDocument (net.opengis.tsml.x10.TimeseriesTVPDocument)3 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)3 DefaultPointMetadata (org.n52.shetland.ogc.om.series.DefaultPointMetadata)3 Metadata (org.n52.shetland.ogc.om.series.Metadata)3 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)3 AbstractGMLType (net.opengis.gml.x32.AbstractGMLType)2 PointMetadataDocument (net.opengis.tsml.x10.PointMetadataDocument)2 PointMetadataType (net.opengis.tsml.x10.PointMetadataType)2 TimeseriesTVPType (net.opengis.tsml.x10.TimeseriesTVPType)2 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)2 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)2 GDurationBuilder (org.apache.xmlbeans.GDurationBuilder)2 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.jupiter.api.Test)2 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)2 InterpolationType (org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType)2