use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class ObservationEncoder method encodeFeatureOfInterest.
private void encodeFeatureOfInterest(OmObservation o, ObjectNode json) throws EncodingException {
OmObservationConstellation oc = o.getObservationConstellation();
json.set(JSONConstants.FEATURE_OF_INTEREST, encodeObjectToJson(oc.getFeatureOfInterest()));
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AbstractAqdResponseEncoder method processObservation.
protected void processObservation(OmObservation observation, TimePeriod timePeriod, TimeInstant resultTime, FeatureCollection featureCollection, AbstractEReportingHeader eReportingHeader, int counter) {
if (observation.isSetPhenomenonTime()) {
// generate gml:id
observation.setGmlId(getObservationId(counter));
// add xlink:href to eReportingHeader.content
eReportingHeader.addContent((AbstractFeature) new OmObservation().setIdentifier(new CodeWithAuthority(getObservationXlink(observation.getGmlId()))));
timePeriod.extendToContain(observation.getPhenomenonTime());
observation.setResultTime(resultTime);
featureCollection.addMember(observation);
}
}
use of org.n52.shetland.ogc.om.OmObservation 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;
}
use of org.n52.shetland.ogc.om.OmObservation 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));
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AbstractOmV20XmlStreamWriter method writeProcedure.
/**
* Write om:procedure encoded or as xlink:href to stream
*
* @throws XMLStreamException
* If an error occurs when writing to stream
* @throws UnsupportedEncoderInputException
* If the procedure could not be encoded
* @throws EncodingException
* If an error occurs when creating elements to be written
*/
protected void writeProcedure() throws XMLStreamException, EncodingException {
empty(OmConstants.QN_OM_20_PROCEDURE);
OmObservation observation = getElement();
addXlinkHrefAttr(observation.getObservationConstellation().getProcedure().getIdentifier());
if (observation.getObservationConstellation().getProcedure().isSetName() && observation.getObservationConstellation().getProcedure().getFirstName().isSetValue()) {
addXlinkTitleAttr(observation.getObservationConstellation().getProcedure().getFirstName().getValue());
}
}
Aggregations