Search in sources :

Example 6 with OmObservableProperty

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

the class OmEncoderv20Test method shouldEncodeFeatureWithNilWhenMissingInObservationTemplate.

@Test
public void shouldEncodeFeatureWithNilWhenMissingInObservationTemplate() throws EncodingException {
    OmObservationConstellation observationTemplate = new OmObservationConstellation();
    String observationType = OmConstants.OBS_TYPE_MEASUREMENT;
    observationTemplate.setObservationType(observationType);
    observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
    OMObservationType encodedObservationTemplate = (OMObservationType) omEncoderv20.encode(observationTemplate);
    Assert.assertThat(encodedObservationTemplate.getFeatureOfInterest().isNil(), Is.is(false));
    Assert.assertThat(encodedObservationTemplate.getFeatureOfInterest().isSetNilReason(), Is.is(true));
    Assert.assertThat(encodedObservationTemplate.getFeatureOfInterest().getNilReason(), Is.is("template"));
}
Also used : OMObservationType(net.opengis.om.x20.OMObservationType) Matchers.containsString(org.hamcrest.Matchers.containsString) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) Test(org.junit.Test)

Example 7 with OmObservableProperty

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

the class OmEncoderv20Test method createComplexObservation.

protected OmObservation createComplexObservation() {
    DateTime now = new DateTime(DateTimeZone.UTC);
    TimeInstant resultTime = new TimeInstant(now);
    TimeInstant phenomenonTime = 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)));
    OmCompositePhenomenon observableProperty = new OmCompositePhenomenon(PARENT_OBSERVABLE_PROPERTY);
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_1));
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_2));
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_3));
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_4));
    observationConstellation.setObservableProperty(observableProperty);
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_COMPLEX_OBSERVATION);
    observationConstellation.addOffering(OFFERING);
    AbstractFeature procedure = new SosProcedureDescriptionUnknownType(PROCEDURE);
    // procedure.setIdentifier(new CodeWithAuthority(PROCEDURE, CODE_SPACE));
    observationConstellation.setProcedure(procedure);
    observation.setObservationConstellation(observationConstellation);
    observation.setParameter(null);
    observation.setResultTime(resultTime);
    observation.setTokenSeparator(TOKEN_SEPERATOR);
    observation.setTupleSeparator(TUPLE_SEPERATOR);
    observation.setValidTime(validTime);
    ComplexValue complexValue = new ComplexValue();
    SweDataRecord sweDataRecord = new SweDataRecord();
    SweQuantity sweQuantity = new SweQuantity();
    sweQuantity.setDefinition(CHILD_OBSERVABLE_PROPERTY_1);
    sweQuantity.setUom("unit");
    sweQuantity.setValue(42.0);
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_1_NAME, sweQuantity));
    SweBoolean sweBoolean = new SweBoolean();
    sweBoolean.setValue(Boolean.TRUE);
    sweBoolean.setDefinition(CHILD_OBSERVABLE_PROPERTY_2);
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_2_NAME, sweBoolean));
    SweCount sweCount = new SweCount();
    sweCount.setDefinition(CHILD_OBSERVABLE_PROPERTY_3);
    sweCount.setValue(42);
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_3_NAME, sweCount));
    SweText sweText = new SweText();
    sweText.setDefinition(CHILD_OBSERVABLE_PROPERTY_4);
    sweText.setValue("42");
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_4_NAME, sweText));
    SweCategory sweCategory = new SweCategory();
    sweCategory.setDefinition(CHILD_OBSERVABLE_PROPERTY_5);
    sweCategory.setCodeSpace(CODE_SPACE);
    sweCategory.setValue("52");
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_5_NAME, sweCategory));
    complexValue.setValue(sweDataRecord);
    observation.setValue(new SingleObservationValue<>(phenomenonTime, complexValue));
    return observation;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) OmCompositePhenomenon(org.n52.shetland.ogc.om.OmCompositePhenomenon) 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) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 8 with OmObservableProperty

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

the class InsertObservationRequestEncoderTest method createInsertObservationRequest.

private InsertObservationRequest createInsertObservationRequest() throws InvalidSridException, ParseException {
    SamplingFeature samplingFeature = new SamplingFeature(new CodeWithAuthority("test-feature-uri"));
    samplingFeature.setName(new CodeType("test-feature-name"));
    samplingFeature.setSampledFeatures(Arrays.asList(new SamplingFeature(new CodeWithAuthority("test-parent-feature-uri"))));
    samplingFeature.setGeometry(JTSHelper.createGeometryFromWKT("POINT(52.0 42.0)", 4326));
    PhysicalSystem procedure = new PhysicalSystem();
    procedure.setIdentifier("test-procedure");
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setGmlId("o1");
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationConstellation.setObservableProperty(new OmObservableProperty("test-property"));
    observationConstellation.setFeatureOfInterest(samplingFeature);
    observationConstellation.setProcedure(procedure);
    TimeInstant time = new TimeInstant(new Date(0));
    QuantityValue quantity = new QuantityValue(23.0, "test-uom");
    ObservationValue<?> value = new SingleObservationValue<>(time, quantity);
    OmObservation omObservation = new OmObservation();
    omObservation.setObservationConstellation(observationConstellation);
    omObservation.setResultTime(time);
    omObservation.setValue(value);
    InsertObservationRequest request = new InsertObservationRequest("SOS", "2.0.0");
    request.setOfferings(Arrays.asList(OFFERING_ID));
    request.addObservation(omObservation);
    return request;
}
Also used : PhysicalSystem(org.n52.shetland.ogc.sensorML.v20.PhysicalSystem) OmObservation(org.n52.shetland.ogc.om.OmObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Date(java.util.Date) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) 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)

Example 9 with OmObservableProperty

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

the class OmEncoderv20Test method shouldEncodeTimeFieldsInObservationTemplate.

@Test
public void shouldEncodeTimeFieldsInObservationTemplate() throws EncodingException {
    OmObservationConstellation observationTemplate = new OmObservationConstellation();
    String observationType = OmConstants.OBS_TYPE_MEASUREMENT;
    observationTemplate.setObservationType(observationType);
    observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
    OMObservationType encodedObservationTemplate = (OMObservationType) omEncoderv20.encode(observationTemplate);
    Assert.assertThat(encodedObservationTemplate.getPhenomenonTime().isNil(), Is.is(false));
    Assert.assertThat(encodedObservationTemplate.getPhenomenonTime().isSetNilReason(), Is.is(true));
    Assert.assertThat(encodedObservationTemplate.getPhenomenonTime().getNilReason(), Is.is("template"));
    Assert.assertThat(encodedObservationTemplate.getResultTime().isNil(), Is.is(false));
    Assert.assertThat(encodedObservationTemplate.getResultTime().isSetNilReason(), Is.is(true));
    Assert.assertThat(encodedObservationTemplate.getResultTime().getNilReason(), Is.is("template"));
}
Also used : OMObservationType(net.opengis.om.x20.OMObservationType) Matchers.containsString(org.hamcrest.Matchers.containsString) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) Test(org.junit.Test)

Example 10 with OmObservableProperty

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

the class OmEncoderv20Test method shouldEncodeFeatureInObservationTemplate.

@Test
public void shouldEncodeFeatureInObservationTemplate() throws EncodingException, InvalidSridException, ParseException, XmlException, IOException {
    // 
    SamplingFeature featureOfInterest = new SamplingFeature(new CodeWithAuthority(featureIdentifier));
    featureOfInterest.setIdentifier(featureIdentifier);
    featureOfInterest.setName(new CodeType(featureName));
    featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
    featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT (30 10)", 4326));
    // 
    SensorML procedure = new SensorML();
    procedure.setIdentifier(procedureIdentifier);
    // 
    OmObservationConstellation observationTemplate = new OmObservationConstellation();
    observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
    observationTemplate.setProcedure(procedure);
    observationTemplate.setFeatureOfInterest(featureOfInterest);
    // 
    OMObservationType omObservation = (OMObservationType) omEncoderv20.encode(observationTemplate);
    // 
    Assert.assertThat(omObservation.getType().getHref(), Is.is(OmConstants.OBS_TYPE_MEASUREMENT));
    Assert.assertThat(omObservation.getPhenomenonTime().isNil(), Is.is(false));
    Assert.assertThat(omObservation.getPhenomenonTime().isSetNilReason(), Is.is(true));
    Assert.assertThat(omObservation.getPhenomenonTime().getNilReason(), Is.is("template"));
    Assert.assertThat(omObservation.getResultTime().isNil(), Is.is(false));
    Assert.assertThat(omObservation.getResultTime().isSetNilReason(), Is.is(true));
    Assert.assertThat(omObservation.getResultTime().getNilReason(), Is.is("template"));
    Assert.assertThat(omObservation.getProcedure().isNil(), Is.is(false));
    Assert.assertThat(omObservation.getProcedure().getHref(), Is.is(procedureIdentifier));
    Assert.assertThat(omObservation.getObservedProperty().isNil(), Is.is(false));
    Assert.assertThat(omObservation.getObservedProperty().getHref(), Is.is(observedProperty));
    Assert.assertThat(omObservation.getFeatureOfInterest(), Matchers.notNullValue());
    XmlObject xmlObject = XmlObject.Factory.parse(omObservation.getFeatureOfInterest().newInputStream());
    Assert.assertThat(xmlObject, Matchers.instanceOf(SFSamplingFeatureDocument.class));
    SFSamplingFeatureType feature = ((SFSamplingFeatureDocument) xmlObject).getSFSamplingFeature();
    Assert.assertThat(feature.getIdentifier().getStringValue(), Is.is(featureIdentifier));
    Assert.assertThat(feature.getNameArray().length, Is.is(1));
    Assert.assertThat(feature.getNameArray(0).getStringValue(), Is.is(featureName));
}
Also used : SFSamplingFeatureType(net.opengis.sampling.x20.SFSamplingFeatureType) OMObservationType(net.opengis.om.x20.OMObservationType) CodeType(org.n52.shetland.ogc.gml.CodeType) SFSamplingFeatureDocument(net.opengis.sampling.x20.SFSamplingFeatureDocument) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SensorML(org.n52.shetland.ogc.sensorML.SensorML) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) Test(org.junit.Test)

Aggregations

OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)14 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)8 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)5 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)5 OMObservationType (net.opengis.om.x20.OMObservationType)4 Test (org.junit.Test)4 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 DateTime (org.joda.time.DateTime)3 CodeType (org.n52.shetland.ogc.gml.CodeType)3 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)3 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)3 OmObservation (org.n52.shetland.ogc.om.OmObservation)3 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)3 MeasureOrNilReasonListType (net.opengis.gml.x32.MeasureOrNilReasonListType)2 QuantityListDocument (net.opengis.gml.x32.QuantityListDocument)2 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)2 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)2 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2