Search in sources :

Example 1 with InterpolationType

use of org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType 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 2 with InterpolationType

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

the class WmlTVPEncoderv20Test method shouldEncodeInterpolationType.

@Test
public void shouldEncodeInterpolationType() throws EncodingException, XmlException {
    final InterpolationType type = WaterMLConstants.InterpolationType.MinPrec;
    mv.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
    XmlObject encodedElement = encoder.encode(mv);
    TVPDefaultMetadataPropertyType defaultPointMetadata = ((MeasurementTimeseriesDocument) encodedElement).getTimeseries().getDefaultPointMetadataArray(0);
    DefaultTVPMeasurementMetadataDocument tvpMeasurementMetadataDocument = DefaultTVPMeasurementMetadataDocument.Factory.parse(defaultPointMetadata.xmlText());
    ReferenceType interpolationType = tvpMeasurementMetadataDocument.getDefaultTVPMeasurementMetadata().getInterpolationType();
    Assert.assertThat(interpolationType.getHref(), Is.is("http://www.opengis.net/def/waterml/2.0/interpolationType/MinPrec"));
    Assert.assertThat(interpolationType.getTitle(), Is.is("MinPrec"));
}
Also used : DefaultPointMetadata(org.n52.shetland.ogc.om.series.wml.DefaultPointMetadata) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata) XmlObject(org.apache.xmlbeans.XmlObject) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType) ReferenceType(net.opengis.gml.x32.ReferenceType) Test(org.junit.Test)

Example 3 with InterpolationType

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

the class WmlTVPEncoderv20XmlStreamWriter method writeInterpolationType.

/**
 * Write wml:interpolationType to stream
 *
 * @throws XMLStreamException
 *             If an error occurs when writing to stream
 */
private void writeInterpolationType(ObservationValue<?> value) throws XMLStreamException {
    empty(WaterMLConstants.QN_INTERPOLATION_TYPE);
    if (value != null && value.isSetMetadata() && value.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        InterpolationType interpolationtype = value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
        addXlinkHrefAttr(interpolationtype.getIdentifier());
        addXlinkTitleAttr(interpolationtype.getTitle());
    } else {
        addXlinkHrefAttr("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
        addXlinkTitleAttr("Instantaneous");
    }
}
Also used : InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)

Example 4 with InterpolationType

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

the class WmlTVPEncoderv20 method createMeasurementTimeseries.

private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws CodedException {
    MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
    MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
    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);
    TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
    TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
    // Default value
    InterpolationType interpolationType = InterpolationType.Continuous;
    if (observationValue.isSetValue() && observationValue.isSetDefaultPointMetadata() && observationValue.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        interpolationType = observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
    }
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().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 : TimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) MeasurementTimeseriesType(net.opengis.waterml.x20.MeasurementTimeseriesType) 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)

Aggregations

InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)4 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)3 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)3 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)2 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)2 MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata)2 TimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata)2 ReferenceType (net.opengis.gml.x32.ReferenceType)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Test (org.junit.Test)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 DefaultPointMetadata (org.n52.shetland.ogc.om.series.wml.DefaultPointMetadata)1 DefaultTVPMeasurementMetadata (org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata)1 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)1