Search in sources :

Example 26 with OmObservationConstellation

use of org.n52.shetland.ogc.om.OmObservationConstellation 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 27 with OmObservationConstellation

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

Example 28 with OmObservationConstellation

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

the class TrajectoryObservationTypeEncoderTest method createObservation.

private OmObservation createObservation() throws DecodingException, XmlException, IOException {
    DateTime now = new DateTime(DateTimeZone.UTC);
    TimeInstant resultTime = new TimeInstant(now);
    TrajectoryObservation observation = new TrajectoryObservation();
    observation.setObservationID("123");
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
    OmObservableProperty observableProperty = new OmObservableProperty(OBSERVABLE_PROPERTY);
    observationConstellation.setObservableProperty(observableProperty);
    observationConstellation.addOffering(OFFERING);
    Process procedure = createProcessFromFile();
    observationConstellation.setProcedure(procedure);
    observation.setObservationConstellation(observationConstellation);
    observation.setResultTime(resultTime);
    return observation;
}
Also used : TrajectoryObservation(org.n52.shetland.inspire.omso.TrajectoryObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) Process(org.n52.shetland.inspire.ompr.Process) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Aggregations

OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)28 Test (org.junit.Test)18 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)8 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)7 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)7 InsertResultTemplateRequest (org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)6 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)5 OMObservationType (net.opengis.om.x20.OMObservationType)4 CodeType (org.n52.shetland.ogc.gml.CodeType)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)3 OmObservation (org.n52.shetland.ogc.om.OmObservation)3 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 DateTime (org.joda.time.DateTime)2 SensorML (org.n52.shetland.ogc.sensorML.SensorML)2 SosResultStructure (org.n52.shetland.ogc.sos.SosResultStructure)2 SweField (org.n52.shetland.ogc.swe.SweField)2 Date (java.util.Date)1 SFSamplingFeatureDocument (net.opengis.sampling.x20.SFSamplingFeatureDocument)1 SFSamplingFeatureType (net.opengis.sampling.x20.SFSamplingFeatureType)1