Search in sources :

Example 1 with InterpolationType

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

the class TsmlTVPEncoderv10Test method shouldEncodeInterpolationType.

@Test
public void shouldEncodeInterpolationType() throws EncodingException, XmlException {
    final InterpolationType type = TimeseriesMLConstants.InterpolationType.MinPrec;
    mv.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
    XmlObject encodedElement = encoder.encode(mv);
    TimeseriesTVPType.DefaultPointMetadata defaultPointMetadata = ((TimeseriesTVPDocument) encodedElement).getTimeseriesTVP().getDefaultPointMetadata();
    PointMetadataDocument tvpMeasurementMetadataDocument = PointMetadataDocument.Factory.parse(defaultPointMetadata.xmlText());
    ReferenceType interpolationType = tvpMeasurementMetadataDocument.getPointMetadata().getInterpolationType();
    MatcherAssert.assertThat(interpolationType.getHref(), Is.is(TimeseriesMLConstants.InterpolationType.MinPrec.getIdentifier()));
    MatcherAssert.assertThat(interpolationType.getTitle(), Is.is(TimeseriesMLConstants.InterpolationType.MinPrec.getTitle()));
}
Also used : DefaultPointMetadata(org.n52.shetland.ogc.om.series.DefaultPointMetadata) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.tsml.DefaultTVPMeasurementMetadata) XmlObject(org.apache.xmlbeans.XmlObject) PointMetadataDocument(net.opengis.tsml.x10.PointMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType) TimeseriesTVPType(net.opengis.tsml.x10.TimeseriesTVPType) ReferenceType(net.opengis.gml.x32.ReferenceType) Test(org.junit.jupiter.api.Test)

Example 2 with InterpolationType

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

the class TsmlTVPEncoderv10Test method createObservation.

private OmObservation createObservation() {
    final InterpolationType type = TimeseriesMLConstants.InterpolationType.InstantTotal;
    DateTime now = new DateTime(DateTimeZone.UTC);
    TimeInstant resultTime = new TimeInstant(now);
    TimePeriod validTime = new TimePeriod(now.minusMinutes(5), now.plusMinutes(5));
    OmObservation observation = new OmObservation();
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
    observationConstellation.setObservableProperty(new OmObservableProperty("omobservableProperty"));
    observationConstellation.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_OBSERVATION);
    observationConstellation.addOffering(OFFERING);
    AbstractFeature procedure = new SosProcedureDescriptionUnknownType(PROCEDURE);
    observationConstellation.setProcedure(procedure);
    observation.setObservationConstellation(observationConstellation);
    observation.setParameter(null);
    observation.setResultTime(resultTime);
    observation.setTokenSeparator(TOKEN_SEPERATOR);
    observation.setTupleSeparator(TUPLE_SEPERATOR);
    observation.setValidTime(validTime);
    observation.setValue(mv);
    return observation;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) DefaultPointMetadata(org.n52.shetland.ogc.om.series.DefaultPointMetadata) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.tsml.DefaultTVPMeasurementMetadata) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) InterpolationType(org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 3 with InterpolationType

use of org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.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();
    assertThat(interpolationType.getHref(), Is.is(WaterMLConstants.InterpolationType.MinPrec.getIdentifier()));
    assertThat(interpolationType.getTitle(), Is.is(WaterMLConstants.InterpolationType.MinPrec.getTitle()));
}
Also used : DefaultPointMetadata(org.n52.shetland.ogc.om.series.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.jupiter.api.Test)

Example 4 with InterpolationType

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

the class WmlTVPEncoderv20XmlStreamWriter method writeInterpolationType.

/**
 * Write wml:interpolationType to stream
 *
 * @param value
 *            the observation value
 *
 * @throws XMLStreamException
 *             If an error occurs when writing to stream
 */
private void writeInterpolationType(@Nullable ObservationValue<?> value) throws XMLStreamException {
    empty(WaterMLConstants.QN_INTERPOLATION_TYPE);
    if (value != null && value.isSetMetadata() && value.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        InterpolationType 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 5 with InterpolationType

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

Aggregations

MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata)5 InterpolationType (org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType)5 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)5 DefaultPointMetadata (org.n52.shetland.ogc.om.series.DefaultPointMetadata)4 TimeseriesMetadata (org.n52.shetland.ogc.om.series.TimeseriesMetadata)4 PointMetadataDocument (net.opengis.tsml.x10.PointMetadataDocument)3 TimeseriesTVPType (net.opengis.tsml.x10.TimeseriesTVPType)3 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)3 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)3 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)3 AbstractGMLType (net.opengis.gml.x32.AbstractGMLType)2 ReferenceType (net.opengis.gml.x32.ReferenceType)2 PointMetadataType (net.opengis.tsml.x10.PointMetadataType)2 TimeseriesTVPDocument (net.opengis.tsml.x10.TimeseriesTVPDocument)2 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)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