Search in sources :

Example 1 with OMObservationDocument

use of net.opengis.om.x20.OMObservationDocument in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method createObservationDocument.

private XmlObject createObservationDocument(OMObservationType xbObservation) {
    OMObservationDocument doc = createObservationDocument();
    doc.setOMObservation(xbObservation);
    return doc;
}
Also used : OMObservationDocument(net.opengis.om.x20.OMObservationDocument)

Example 2 with OMObservationDocument

use of net.opengis.om.x20.OMObservationDocument in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method createWmlGetObservationResponse.

/**
 * Encodes a SOS GetObservationResponse to a single WaterML 2.0 observation
 * or to a WaterML 1.0 ObservationCollection
 *
 * @param getObservationResonse
 *            SOS GetObservationResponse
 * @return Encoded response
 * @throws EncodingException
 *             If an error occurs
 */
protected XmlObject createWmlGetObservationResponse(GetObservationResponse getObservationResonse) throws EncodingException {
    // TODO: set schemaLocation if final
    Map<CodeWithAuthority, String> gmlID4sfIdentifier = Maps.newHashMap();
    int sfIdCounter = 1;
    try {
        if (getObservationResonse.getObservationCollection() != null && !getObservationResonse.getObservationCollection().hasNext()) {
            ObservationStream observations = getObservationResonse.getObservationCollection();
            OmObservation observation = observations.next();
            if (!observations.hasNext()) {
                OMObservationDocument omObservationDoc = OMObservationDocument.Factory.newInstance(getXmlOptions());
                omObservationDoc.setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
                sfIdCounter++;
                return omObservationDoc;
            } else {
                CollectionDocument xmlCollectionDoc = CollectionDocument.Factory.newInstance(getXmlOptions());
                CollectionType wmlCollection = xmlCollectionDoc.addNewCollection();
                wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
                sfIdCounter++;
                while (observations.hasNext()) {
                    wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observations.next(), gmlID4sfIdentifier, sfIdCounter));
                    sfIdCounter++;
                }
                return xmlCollectionDoc;
            }
        } else {
            // TODO: HydrologieProfile-Exception
            throw new EncodingException("Combination does not exists!");
        }
    } catch (NoSuchElementException | OwsExceptionReport e) {
        throw new EncodingException(e);
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) CollectionDocument(net.opengis.waterml.x20.CollectionDocument) OmObservation(org.n52.shetland.ogc.om.OmObservation) OMObservationDocument(net.opengis.om.x20.OMObservationDocument) WmlMonitoringPoint(org.n52.shetland.ogc.om.series.wml.WmlMonitoringPoint) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) CollectionType(net.opengis.waterml.x20.CollectionType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

OMObservationDocument (net.opengis.om.x20.OMObservationDocument)2 NoSuchElementException (java.util.NoSuchElementException)1 CollectionDocument (net.opengis.waterml.x20.CollectionDocument)1 CollectionType (net.opengis.waterml.x20.CollectionType)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 WmlMonitoringPoint (org.n52.shetland.ogc.om.series.wml.WmlMonitoringPoint)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1