Search in sources :

Example 1 with SFSamplingFeatureDocument

use of net.opengis.sampling.x20.SFSamplingFeatureDocument in project arctic-sea by 52North.

the class InsertResultTemplateRequestEncoderTest method shouldEncodeObservationTemplate.

@Test
public void shouldEncodeObservationTemplate() throws EncodingException, XmlException, IOException {
    ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
    ObservationTemplate observationTemplate = template.getObservationTemplate();
    Assert.assertThat(observationTemplate, Matchers.notNullValue());
    Assert.assertThat(observationTemplate, Matchers.instanceOf(ObservationTemplate.class));
    OMObservationType omObservation = observationTemplate.getOMObservation();
    Assert.assertThat(omObservation, Matchers.instanceOf(OMObservationType.class));
    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) ObservationTemplate(net.opengis.sos.x20.ResultTemplateType.ObservationTemplate) OMObservationType(net.opengis.om.x20.OMObservationType) SFSamplingFeatureDocument(net.opengis.sampling.x20.SFSamplingFeatureDocument) XmlObject(org.apache.xmlbeans.XmlObject) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) Test(org.junit.Test)

Example 2 with SFSamplingFeatureDocument

use of net.opengis.sampling.x20.SFSamplingFeatureDocument 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

OMObservationType (net.opengis.om.x20.OMObservationType)2 SFSamplingFeatureDocument (net.opengis.sampling.x20.SFSamplingFeatureDocument)2 SFSamplingFeatureType (net.opengis.sampling.x20.SFSamplingFeatureType)2 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.Test)2 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)1 InsertResultTemplateType (net.opengis.sos.x20.InsertResultTemplateType)1 ResultTemplateType (net.opengis.sos.x20.ResultTemplateType)1 ObservationTemplate (net.opengis.sos.x20.ResultTemplateType.ObservationTemplate)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)1 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)1 SensorML (org.n52.shetland.ogc.sensorML.SensorML)1