Search in sources :

Example 1 with DefaultTVPMeasurementMetadata

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

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

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

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

the class UVFEncoderTest method initObjects.

@BeforeEach
public void initObjects() throws OwsExceptionReport, ParseException {
    encoder = new UVFEncoder();
    final OmObservation omObservation = new OmObservation();
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    omObservation.setObservationID("1");
    // Observed Property
    String valueType = "test-obs-prop-value-type";
    String description = "test-obs-prop-description";
    AbstractPhenomenon observableProperty = new OmObservableProperty(obsPropIdentifier, description, unit, valueType);
    observationConstellation.setObservableProperty(observableProperty);
    // Feature Of Interest
    CodeWithAuthority featureIdentifier = new CodeWithAuthority(foiIdentifier);
    AbstractFeature featureOfInterest = new SamplingFeature(featureIdentifier);
    featureOfInterest.addName(new CodeType(foiName));
    int srid = 4326;
    String geomWKT = "POINT(51.9350382 7.6521225)";
    final Geometry point = JTSHelper.createGeometryFromWKT(geomWKT, srid);
    ((SamplingFeature) featureOfInterest).setGeometry(point);
    observationConstellation.setFeatureOfInterest(featureOfInterest);
    // value
    final String uomId = "test-uom";
    final double testValue = 52.0;
    Value<?> measuredValue = new QuantityValue(testValue, uomId);
    // timestamps
    Time phenomenonTime = new TimeInstant(new Date(UTC_TIMESTAMP_1));
    // observation value
    ObservationValue<?> value = new SingleObservationValue<>(phenomenonTime, measuredValue);
    value.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(InterpolationType.Continuous)));
    omObservation.setValue(value);
    // observation type
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    // Final package
    omObservation.setObservationConstellation(observationConstellation);
    responseToEncode = new GetObservationResponse();
    responseToEncode.setObservationCollection(ObservationStream.of(omObservation));
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) GetObservationResponse(org.n52.shetland.ogc.sos.response.GetObservationResponse) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) Time(org.n52.shetland.ogc.gml.time.Time) DateTime(org.joda.time.DateTime) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Date(java.util.Date) Geometry(org.locationtech.jts.geom.Geometry) DefaultPointMetadata(org.n52.shetland.ogc.om.series.DefaultPointMetadata) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata) CodeType(org.n52.shetland.ogc.gml.CodeType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with DefaultTVPMeasurementMetadata

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

the class TrajectoryObservationTypeEncoder method createMeasurementTimeseries.

/**
 * Encode {@link AbstractObservationValue} to
 * {@link MeasurementTimeseriesDocument}
 *
 * @param observationValue
 *            The {@link AbstractObservationValue} to encode
 * @return The encoded {@link AbstractObservationValue}
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws EncodingException {
    MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
    MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
    if (!observationValue.isSetObservationID()) {
        observationValue.setObservationID(IdGenerator.generate(observationValue.toString()));
    }
    measurementTimeseries.setId(TIMESERIES_PREFIX + observationValue.getObservationID());
    measurementTimeseries.addNewMetadata().addNewTimeseriesMetadata().addNewTemporalExtent().setHref("#" + observationValue.getPhenomenonTime().getGmlId());
    TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
    TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle("Instantaneous");
    String unit = null;
    if (observationValue instanceof SingleObservationValue) {
        SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
        unit = singleObservationValue.getValue().getUnit();
        if (observationValue.getValue() instanceof TimeLocationValueTriple) {
            measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT((TimeLocationValueTriple) observationValue.getValue()));
        }
    } else if (observationValue instanceof MultiObservationValues) {
        MultiObservationValues<?> multiObservationValue = (MultiObservationValues<?>) observationValue;
        if (multiObservationValue.getValue() instanceof TLVTValue) {
            TLVTValue tlvtValue = (TLVTValue) multiObservationValue.getValue();
            List<TimeLocationValueTriple> timeLocationValueTriples = tlvtValue.getValue();
            unit = tlvtValue.getUnit();
            int counter = 0;
            for (TimeLocationValueTriple timeLocationValueTriple : timeLocationValueTriples) {
                timeLocationValueTriple.getLocation().setUserData(getUserObject(observationValue.getObservationID(), counter));
                measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT(timeLocationValueTriple));
                counter++;
            }
        }
    }
    if (unit != null && !unit.isEmpty()) {
        defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
    }
    xbMetaComponent.set(xbDefMeasureMetaComponent);
    return measurementTimeseriesDoc;
}
Also used : MeasurementTimeseriesType(net.opengis.waterml.x20.MeasurementTimeseriesType) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) TVPMeasurementMetadataType(net.opengis.waterml.x20.TVPMeasurementMetadataType) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) List(java.util.List) MeasurementTimeseriesDocument(net.opengis.waterml.x20.MeasurementTimeseriesDocument) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues)

Aggregations

DefaultPointMetadata (org.n52.shetland.ogc.om.series.DefaultPointMetadata)5 MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata)5 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)4 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)4 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)4 TimeseriesMetadata (org.n52.shetland.ogc.om.series.TimeseriesMetadata)4 InterpolationType (org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType)4 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)4 PointMetadataDocument (net.opengis.tsml.x10.PointMetadataDocument)3 TimeseriesTVPType (net.opengis.tsml.x10.TimeseriesTVPType)3 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)3 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)3 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)3 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)3 DefaultTVPMeasurementMetadata (org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata)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 GDurationBuilder (org.apache.xmlbeans.GDurationBuilder)2