Search in sources :

Example 21 with CodeWithAuthority

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

Example 22 with CodeWithAuthority

use of org.n52.shetland.ogc.gml.CodeWithAuthority in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method checkAndAddIdentifier.

private void checkAndAddIdentifier(ObservationProcess op, ObservationProcessType opt) throws EncodingException {
    if (op.isSetIdentifier() && !opt.isSetIdentifier()) {
        CodeWithAuthority codeWithAuthority = op.getIdentifierCodeWithAuthority();
        Encoder<?, CodeWithAuthority> encoder = getEncoder(getEncoderKey(GmlConstants.NS_GML_32, codeWithAuthority));
        if (encoder != null) {
            XmlObject xmlObject = (XmlObject) encoder.encode(codeWithAuthority);
            opt.addNewIdentifier().set(xmlObject);
        } else {
            throw new EncodingException("Error while encoding geometry value, needed encoder is missing!");
        }
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 23 with CodeWithAuthority

use of org.n52.shetland.ogc.gml.CodeWithAuthority in project arctic-sea by 52North.

the class AqdEncoder 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);
    }
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 24 with CodeWithAuthority

use of org.n52.shetland.ogc.gml.CodeWithAuthority in project arctic-sea by 52North.

the class AbstractProcessDecoder method parseInspireId.

private void parseInspireId(ProcessType pt, Process process) {
    IdentifierType identifier = pt.getInspireId().getIdentifier();
    String localId = identifier.getLocalId();
    String namespace = identifier.getNamespace();
    CodeWithAuthority codeWithAuthority;
    if (localId.contains(namespace)) {
        codeWithAuthority = new CodeWithAuthority(localId, namespace);
    } else {
        codeWithAuthority = new CodeWithAuthority(getIdentifier(localId, namespace), namespace);
    }
    process.setIdentifier(codeWithAuthority);
}
Also used : CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) IdentifierType(eu.europa.ec.inspire.schemas.base.x33.IdentifierType)

Example 25 with CodeWithAuthority

use of org.n52.shetland.ogc.gml.CodeWithAuthority 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);
    }
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Aggregations

CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)28 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)17 Test (org.junit.Test)9 CodeType (org.n52.shetland.ogc.gml.CodeType)7 XmlObject (org.apache.xmlbeans.XmlObject)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)6 SamplingFeatureComplex (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex)6 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)5 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)5 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)4 EncodingException (org.n52.svalbard.encode.exception.EncodingException)4 ArrayList (java.util.ArrayList)3 DateTime (org.joda.time.DateTime)3 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)3 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)3 XmlException (org.apache.xmlbeans.XmlException)2 XmlOptions (org.apache.xmlbeans.XmlOptions)2 Before (org.junit.Before)2 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)2 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)2