Search in sources :

Example 1 with GetObservationByIdResponseType

use of net.opengis.sos.x20.GetObservationByIdResponseType in project arctic-sea by 52North.

the class GetObservationByIdResponseEncoder method createResponse.

@Override
protected XmlObject createResponse(ObservationEncoder<XmlObject, OmObservation> encoder, GetObservationByIdResponse response) throws EncodingException {
    GetObservationByIdResponseDocument doc = GetObservationByIdResponseDocument.Factory.newInstance(getXmlOptions());
    GetObservationByIdResponseType xbResponse = doc.addNewGetObservationByIdResponse();
    ObservationStream observations = getObservationsAndCheckForStreaming(response, encoder);
    HashMap<CodeWithAuthority, String> gmlID4sfIdentifier = new HashMap<>();
    try {
        while (observations.hasNext()) {
            OmObservation observation = observations.next();
            EncodingContext codingContext = EncodingContext.empty();
            CodeWithAuthority foiId = observation.getObservationConstellation().getFeatureOfInterest().getIdentifierCodeWithAuthority();
            if (gmlID4sfIdentifier.containsKey(foiId)) {
                codingContext = codingContext.with(XmlBeansEncodingFlags.EXIST_FOI_IN_DOC, true);
            } else {
                gmlID4sfIdentifier.put(foiId, GML_ID);
                codingContext = codingContext.with(XmlBeansEncodingFlags.EXIST_FOI_IN_DOC, false);
            }
            codingContext = codingContext.with(XmlBeansEncodingFlags.GMLID, gmlID4sfIdentifier.get(foiId));
            xbResponse.addNewObservation().addNewOMObservation().set(encoder.encode(observation, codingContext));
        }
    } catch (OwsExceptionReport ex) {
        throw new EncodingException(ex);
    }
    XmlHelper.makeGmlIdsUnique(xbResponse.getDomNode());
    return doc;
}
Also used : ObservationStream(org.n52.shetland.ogc.om.ObservationStream) HashMap(java.util.HashMap) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OmObservation(org.n52.shetland.ogc.om.OmObservation) GetObservationByIdResponseDocument(net.opengis.sos.x20.GetObservationByIdResponseDocument) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) GetObservationByIdResponseType(net.opengis.sos.x20.GetObservationByIdResponseType)

Example 2 with GetObservationByIdResponseType

use of net.opengis.sos.x20.GetObservationByIdResponseType in project arctic-sea by 52North.

the class GetObservationByIdResponseDocumentDecoder method decode.

@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public GetObservationByIdResponse decode(GetObservationByIdResponseDocument doc) throws DecodingException {
    if (doc != null) {
        GetObservationByIdResponse response = new GetObservationByIdResponse();
        setService(response);
        setVersions(response);
        GetObservationByIdResponseType type = doc.getGetObservationByIdResponse();
        response.setExtensions(parseExtensibleResponse(type));
        response.setObservationCollection(ObservationStream.of(parseObservations(type)));
        return response;
    }
    throw new UnsupportedDecoderInputException(this, doc);
}
Also used : GetObservationByIdResponse(org.n52.shetland.ogc.sos.response.GetObservationByIdResponse) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) GetObservationByIdResponseType(net.opengis.sos.x20.GetObservationByIdResponseType) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

GetObservationByIdResponseType (net.opengis.sos.x20.GetObservationByIdResponseType)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 HashMap (java.util.HashMap)1 GetObservationByIdResponseDocument (net.opengis.sos.x20.GetObservationByIdResponseDocument)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 GetObservationByIdResponse (org.n52.shetland.ogc.sos.response.GetObservationByIdResponse)1 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1