Search in sources :

Example 1 with DefaultPointMetadata

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

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

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

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

use of org.n52.shetland.ogc.om.series.DefaultPointMetadata in project SOS by 52North.

the class WaterMLMetadataAdder method add.

public WaterMLMetadataAdder add() throws CodedException {
    if (series.hasParameters()) {
        OmObservationConstellation observationConstellation = omObservation.getObservationConstellation();
        /*
             * Add interpolation type
             */
        if (!observationConstellation.isSetDefaultPointMetadata()) {
            observationConstellation.setDefaultPointMetadata(new DefaultPointMetadata());
        }
        if (!observationConstellation.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata()) {
            observationConstellation.getDefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata());
        }
        /*
             * Get interpolation type from database
             */
        Optional<Object> interpolationTypeTitle = getMetadataElement(series, WaterMLConstants.NS_WML_20, WaterMLConstants.INTERPOLATION_TYPE);
        /*
             * Default Value
             */
        InterpolationType interpolationType = WaterMLConstants.InterpolationType.Continuous;
        if (interpolationTypeTitle.isPresent()) {
            try {
                interpolationType = InterpolationType.from(interpolationTypeTitle.get().toString());
            } catch (IllegalArgumentException iae) {
                throw createMetadataInvalidException(WaterMLConstants.INTERPOLATION_TYPE, interpolationType.getTitle(), iae);
            }
        }
        observationConstellation.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().setInterpolationtype(interpolationType);
        /*
             * Add cumulative
             */
        if (!observationConstellation.isSetMetadata()) {
            observationConstellation.setMetadata(new Metadata());
        }
        if (!observationConstellation.getMetadata().isSetTimeseriesMetadata()) {
            observationConstellation.getMetadata().setTimeseriesmetadata(new MeasurementTimeseriesMetadata());
        }
        Optional<Object> cumulativeMetadata = getMetadataElement(series, WaterMLConstants.NS_WML_20, WaterMLConstants.SERIES_METADATA_CUMULATIVE);
        /*
             * Default Value
             */
        boolean cumulative = false;
        if (cumulativeMetadata.isPresent()) {
            String cumulativeMetadataValue = cumulativeMetadata.get().toString();
            if (!cumulativeMetadataValue.isEmpty() && (cumulativeMetadataValue.equalsIgnoreCase("true") || cumulativeMetadataValue.equalsIgnoreCase("false") || cumulativeMetadataValue.equalsIgnoreCase("1") || cumulativeMetadataValue.equalsIgnoreCase("0"))) {
                if (cumulativeMetadataValue.equals("1")) {
                    cumulative = true;
                } else {
                    cumulative = Boolean.parseBoolean(cumulativeMetadataValue);
                }
            } else {
                throw createMetadataInvalidException(WaterMLConstants.SERIES_METADATA_CUMULATIVE, cumulativeMetadataValue, null);
            }
        }
        ((MeasurementTimeseriesMetadata) observationConstellation.getMetadata().getTimeseriesmetadata()).setCumulative(cumulative);
    }
    return this;
}
Also used : DefaultPointMetadata(org.n52.shetland.ogc.om.series.DefaultPointMetadata) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) DefaultPointMetadata(org.n52.shetland.ogc.om.series.DefaultPointMetadata) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata) Metadata(org.n52.shetland.ogc.om.series.Metadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.MeasurementTimeseriesMetadata) InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation)

Aggregations

DefaultPointMetadata (org.n52.shetland.ogc.om.series.DefaultPointMetadata)5 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)3 DefaultTVPMeasurementMetadata (org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata)3 ReferenceType (net.opengis.gml.x32.ReferenceType)2 XmlObject (org.apache.xmlbeans.XmlObject)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.jupiter.api.Test)2 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)2 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)2 OmObservation (org.n52.shetland.ogc.om.OmObservation)2 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)2 DefaultTVPMeasurementMetadata (org.n52.shetland.ogc.om.series.tsml.DefaultTVPMeasurementMetadata)2 InterpolationType (org.n52.shetland.ogc.om.series.tsml.TimeseriesMLConstants.InterpolationType)2 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)2 Date (java.util.Date)1 PointMetadataDocument (net.opengis.tsml.x10.PointMetadataDocument)1 TimeseriesTVPType (net.opengis.tsml.x10.TimeseriesTVPType)1 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)1