use of org.n52.shetland.ogc.sos.response.GetObservationResponse in project arctic-sea by 52North.
the class GetObservationResponseDocumentDecoder method decode.
@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public GetObservationResponse decode(GetObservationResponseDocument gord) throws DecodingException {
if (gord != null) {
GetObservationResponse response = new GetObservationResponse();
setService(response);
setVersions(response);
GetObservationResponseType gort = gord.getGetObservationResponse();
response.setExtensions(parseExtensibleResponse(gort));
response.setObservationCollection(ObservationStream.of(parseObservtions(gort)));
return response;
}
throw new UnsupportedDecoderInputException(this, gord);
}
use of org.n52.shetland.ogc.sos.response.GetObservationResponse in project arctic-sea by 52North.
the class OmEncoderv100 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof OmObservation) {
encodedObject = createObservation((OmObservation) element, additionalValues);
} else if (element instanceof GetObservationResponse) {
GetObservationResponse response = (GetObservationResponse) element;
encodedObject = createObservationCollection(response.getObservationCollection(), response.getResultModel());
} else if (element instanceof GetObservationByIdResponse) {
GetObservationByIdResponse response = (GetObservationByIdResponse) element;
encodedObject = createObservationCollection(response.getObservationCollection(), response.getResultModel());
} else {
throw new UnsupportedEncoderInputException(this, element);
}
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
use of org.n52.shetland.ogc.sos.response.GetObservationResponse in project arctic-sea by 52North.
the class GetObservationResponseEncoder method createResponse.
@Override
protected void createResponse(ObservationEncoder<XmlObject, OmObservation> encoder, GetObservationResponse response, OutputStream outputStream, EncodingContext ctx) throws EncodingException {
try {
EncodingContext context = ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()).with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions).with(StreamingEncoderFlags.ENCODER, this);
new GetObservationResponseXmlStreamWriter(context, outputStream, response).write();
} catch (XMLStreamException xmlse) {
throw new EncodingException(xmlse);
}
}
use of org.n52.shetland.ogc.sos.response.GetObservationResponse in project arctic-sea by 52North.
the class GetObservationResponseEncoder method createResponse.
@Override
protected XmlObject createResponse(ObservationEncoder<XmlObject, OmObservation> encoder, GetObservationResponse response) throws EncodingException {
try {
GetObservationResponseDocument doc = GetObservationResponseDocument.Factory.newInstance(getXmlOptions());
GetObservationResponseType xbResponse = doc.addNewGetObservationResponse();
ObservationStream observationCollection = response.getObservationCollection();
while (observationCollection.hasNext()) {
xbResponse.addNewObservationData().addNewOMObservation().set(encoder.encode(observationCollection.next()));
}
// in a single observation the gml:ids must be unique
XmlHelper.makeGmlIdsUnique(doc.getDomNode());
return doc;
} catch (OwsExceptionReport ex) {
throw new EncodingException(ex);
}
}
use of org.n52.shetland.ogc.sos.response.GetObservationResponse in project arctic-sea by 52North.
the class AqdEncoder method encodeGetObservationResponse.
private XmlObject encodeGetObservationResponse(GetObservationResponse response, EncodingContext ctx) throws EncodingException {
try {
FeatureCollection featureCollection = getFeatureCollection(response);
// TODO get FLOW from response
EReportingHeader eReportingHeader = getEReportingHeader(getReportObligationType(response));
featureCollection.addMember(eReportingHeader);
TimePeriod timePeriod = new TimePeriod();
TimeInstant resultTime = new TimeInstant(new DateTime(DateTimeZone.UTC));
int counter = 1;
ObservationStream observationCollection = response.getObservationCollection();
while (observationCollection.hasNext()) {
OmObservation observation = observationCollection.next();
if (observation.getValue() instanceof ObservationStream) {
ObservationStream value = (ObservationStream) observation.getValue();
if (value instanceof StreamingValue) {
value = value.merge();
}
while (value.hasNext()) {
processObservation(value.next(), timePeriod, resultTime, featureCollection, eReportingHeader, counter++);
}
} else {
processObservation(observation, timePeriod, resultTime, featureCollection, eReportingHeader, counter++);
}
}
if (!timePeriod.isEmpty()) {
eReportingHeader.setReportingPeriod(Referenceable.of((Time) timePeriod));
}
return encodeObjectToXml(GmlConstants.NS_GML_32, featureCollection, ctx.with(XmlEncoderFlags.ENCODE_NAMESPACE, OmConstants.NS_OM_2).with(XmlBeansEncodingFlags.DOCUMENT));
} catch (OwsExceptionReport ex) {
throw new EncodingException(ex);
}
}
Aggregations