Search in sources :

Example 1 with PointMetadataDocument

use of net.opengis.tsml.x10.PointMetadataDocument 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 PointMetadataDocument

use of net.opengis.tsml.x10.PointMetadataDocument 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 3 with PointMetadataDocument

use of net.opengis.tsml.x10.PointMetadataDocument in project arctic-sea by 52North.

the class TsmlTVPEncoderv10 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 {
    TimeseriesTVPDocument measurementTimeseriesDoc = TimeseriesTVPDocument.Factory.newInstance();
    TimeseriesTVPType measurementTimeseries = measurementTimeseriesDoc.addNewTimeseriesTVP();
    ((AbstractGMLType) 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);
    TimeseriesTVPType.DefaultPointMetadata xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    PointMetadataDocument xbDefMeasureMetaComponent = PointMetadataDocument.Factory.newInstance();
    PointMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewPointMetadata();
    // Default value
    InterpolationType interpolationType = InterpolationType.Continuous;
    if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getValue().getValue().getClass().isAssignableFrom(TVPValue.class) && 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.getPointMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
    // set aggregationDuration
    if (sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetAggregationDuration()) {
        GDurationBuilder gDurationBuilder = new GDurationBuilder(sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getAggregationDuration());
        xbDefMeasureMetaComponent.getPointMetadata().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) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) TimeseriesTVPDocument(net.opengis.tsml.x10.TimeseriesTVPDocument) AbstractGMLType(net.opengis.gml.x32.AbstractGMLType) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) PointMetadataDocument(net.opengis.tsml.x10.PointMetadataDocument) GDurationBuilder(org.apache.xmlbeans.GDurationBuilder) TimeseriesTVPType(net.opengis.tsml.x10.TimeseriesTVPType) PointMetadataType(net.opengis.tsml.x10.PointMetadataType) InterpolationType(org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 4 with PointMetadataDocument

use of net.opengis.tsml.x10.PointMetadataDocument in project arctic-sea by 52North.

the class TsmlTVPEncoderv10Test method shouldEncodeInterpolationTypeContinuousAsDefault.

@Test
public void shouldEncodeInterpolationTypeContinuousAsDefault() throws EncodingException, XmlException {
    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.Continuous.getIdentifier()));
    MatcherAssert.assertThat(interpolationType.getTitle(), Is.is(TimeseriesMLConstants.InterpolationType.Continuous.getTitle()));
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) PointMetadataDocument(net.opengis.tsml.x10.PointMetadataDocument) TimeseriesTVPType(net.opengis.tsml.x10.TimeseriesTVPType) ReferenceType(net.opengis.gml.x32.ReferenceType) Test(org.junit.jupiter.api.Test)

Aggregations

PointMetadataDocument (net.opengis.tsml.x10.PointMetadataDocument)4 TimeseriesTVPType (net.opengis.tsml.x10.TimeseriesTVPType)4 InterpolationType (org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType)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 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.jupiter.api.Test)2 MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata)2 TimeseriesMetadata (org.n52.shetland.ogc.om.series.TimeseriesMetadata)2 GDurationBuilder (org.apache.xmlbeans.GDurationBuilder)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 DefaultPointMetadata (org.n52.shetland.ogc.om.series.DefaultPointMetadata)1 DefaultTVPMeasurementMetadata (org.n52.shetland.ogc.om.series.tsml.DefaultTVPMeasurementMetadata)1 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)1