Search in sources :

Example 11 with OmObservationConstellation

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

the class InsertResultTemplateRequestEncoderTest method setup.

@Before
public void setup() throws InvalidSridException, ParseException {
    SensorML procedure = new SensorML();
    procedure.setIdentifier(procedureIdentifier);
    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));
    observationTemplate = new OmObservationConstellation();
    observationTemplate.addOffering(offering);
    observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationTemplate.setProcedure(procedure);
    observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
    observationTemplate.setFeatureOfInterest(featureOfInterest);
    SweTextEncoding textEncoding = new SweTextEncoding();
    textEncoding.setBlockSeparator(blockSeparator);
    textEncoding.setTokenSeparator(tokenSeparator);
    SweDataRecord resultStructure = new SweDataRecord();
    SweTime sweTime = new SweTime();
    sweTime.setDefinition(field1Definition);
    sweTime.setUom(field1Uom);
    resultStructure.addField(new SweField(field1Name, sweTime));
    request = new InsertResultTemplateRequest(SosConstants.SOS, Sos2Constants.SERVICEVERSION, Sos2Constants.Operations.InsertResultTemplate.name());
    request.setResultEncoding(new SosResultEncoding(textEncoding));
    request.setResultStructure(new SosResultStructure(resultStructure));
    request.setIdentifier(templateIdentifier);
    request.setObservationTemplate(observationTemplate);
    Supplier<XmlOptions> xmlOptions = () -> new XmlOptions();
    encoder = new InsertResultTemplateRequestEncoder();
    encoder.setXmlOptions(xmlOptions);
    OmEncoderv20 omEncoder = new OmEncoderv20();
    omEncoder.setXmlOptions(xmlOptions);
    SamplingEncoderv20 samsEncoder = new SamplingEncoderv20();
    samsEncoder.setXmlOptions(xmlOptions);
    GmlEncoderv321 gml32Encoder = new GmlEncoderv321();
    gml32Encoder.setXmlOptions(xmlOptions);
    SweCommonEncoderv20 sweEncoderv20 = new SweCommonEncoderv20();
    sweEncoderv20.setXmlOptions(xmlOptions);
    EncoderRepository encoderRepository = new EncoderRepository();
    encoderRepository.setEncoders(Arrays.asList(encoder, omEncoder, samsEncoder, gml32Encoder, sweEncoderv20));
    encoderRepository.init();
    encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) XmlOptions(org.apache.xmlbeans.XmlOptions) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) CodeType(org.n52.shetland.ogc.gml.CodeType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Before(org.junit.Before)

Example 12 with OmObservationConstellation

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

the class InsertResultTemplateRequestEncoderTest method shouldThrowExceptionWhenResultStructureIsMissing.

@Test
public void shouldThrowExceptionWhenResultStructureIsMissing() throws EncodingException {
    thrown.expect(UnsupportedEncoderInputException.class);
    thrown.expectMessage(Is.is("Encoder " + InsertResultTemplateRequestEncoder.class.getSimpleName() + " can not encode 'missing resultStructure'"));
    request = new InsertResultTemplateRequest("service", "version");
    request.setObservationTemplate(new OmObservationConstellation());
    OmObservationConstellation observationTemplate = new OmObservationConstellation();
    observationTemplate.addOffering(offering);
    request.setObservationTemplate(observationTemplate);
    encoder.create(request);
}
Also used : OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 13 with OmObservationConstellation

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

the class InsertResultTemplateRequestEncoderTest method shouldThrowExceptionWhenResultEncodingIsMissing.

@Test
public void shouldThrowExceptionWhenResultEncodingIsMissing() throws EncodingException {
    thrown.expect(UnsupportedEncoderInputException.class);
    thrown.expectMessage(Is.is("Encoder " + InsertResultTemplateRequestEncoder.class.getSimpleName() + " can not encode 'missing resultEncoding'"));
    request = new InsertResultTemplateRequest("service", "version");
    request.setObservationTemplate(new OmObservationConstellation());
    request.setResultStructure(new SosResultStructure(new SweDataRecord()));
    OmObservationConstellation observationTemplate = new OmObservationConstellation();
    observationTemplate.addOffering(offering);
    request.setObservationTemplate(observationTemplate);
    encoder.create(request);
}
Also used : SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 14 with OmObservationConstellation

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

the class OmEncoderv20Test method shouldEncodeObservationTypeInObservationTemplate.

@Test
public void shouldEncodeObservationTypeInObservationTemplate() 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.getType().getHref(), Is.is(observationType));
}
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 15 with OmObservationConstellation

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

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