Search in sources :

Example 26 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method encodeResultQualities.

private void encodeResultQualities(OMObservationType xbObservation, Set<OmResultQuality> resultQuality) throws EncodingException {
    for (OmResultQuality quality : resultQuality) {
        AbstractDQElementDocument encodedQuality = (AbstractDQElementDocument) encodeObjectToXml(null, quality, EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT));
        DQElementPropertyType addNewResultQuality = xbObservation.addNewResultQuality();
        addNewResultQuality.setAbstractDQElement(encodedQuality.getAbstractDQElement());
        XmlHelper.substituteElement(addNewResultQuality.getAbstractDQElement(), encodedQuality.getAbstractDQElement());
    }
}
Also used : DQElementPropertyType(org.isotc211.x2005.gmd.DQElementPropertyType) OmResultQuality(org.n52.shetland.ogc.om.quality.OmResultQuality) AbstractDQElementDocument(org.isotc211.x2005.gmd.AbstractDQElementDocument)

Example 27 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method setFeatureOfInterest.

private void setFeatureOfInterest(OmObservation observation, OMObservationType xb) throws EncodingException {
    AbstractFeature foi = observation.getObservationConstellation().getFeatureOfInterest();
    XmlObject xbFoi = encodeFeatureOfInterest(foi);
    xb.addNewFeatureOfInterest().set(xbFoi);
}
Also used : AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject)

Example 28 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method setMetaDataProperty.

private void setMetaDataProperty(OmObservation sosObservation, OMObservationType xbObservation) throws EncodingException {
    if (sosObservation.isSetMetaDataProperty()) {
        for (AbstractMetaData abstractMetaData : sosObservation.getMetaDataProperty()) {
            XmlObject encodeObject = encodeGML(abstractMetaData);
            XmlObject substituteElement = XmlHelper.substituteElement(xbObservation.addNewMetaDataProperty().addNewAbstractMetaData(), encodeObject);
            substituteElement.set(encodeObject);
        }
    }
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) AbstractMetaData(org.n52.shetland.ogc.gml.AbstractMetaData)

Example 29 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractCoverageEncoder method encodeValueList.

/**
 * Encode value list of {@link RangeSetType} from {@link DiscreteCoverage}
 *
 * @param rst
 *            The {@link RangeSetType} to encode value list for
 * @param discreteCoverage
 *            The {@link DiscreteCoverage} with the value list
 * @throws EncodingException
 *             If an error occurs
 */
protected void encodeValueList(RangeSetType rst, DiscreteCoverage<?> discreteCoverage) throws EncodingException {
    List<?> list = getList(discreteCoverage);
    Value<?> value = discreteCoverage.getRangeSet().iterator().next();
    if (value instanceof BooleanValue) {
        BooleanListDocument bld = BooleanListDocument.Factory.newInstance(getXmlOptions());
        bld.setBooleanList(list);
        rst.set(bld);
    } else if (value instanceof CategoryValue || value instanceof TextValue) {
        DataBlockType dbt = rst.addNewDataBlock();
        dbt.addNewRangeParameters().setHref(discreteCoverage.getRangeParameters());
        CoordinatesType ct = dbt.addNewTupleList();
        ct.setCs(",");
        ct.setStringValue(Joiner.on(",").join(list));
    } else if (value instanceof CountValue) {
        CountListDocument cld = CountListDocument.Factory.newInstance(getXmlOptions());
        cld.setCountList(list);
        rst.set(cld);
    } else if (value instanceof QuantityValue) {
        QuantityListDocument qld = QuantityListDocument.Factory.newInstance(getXmlOptions());
        MeasureOrNilReasonListType monrlt = qld.addNewQuantityList();
        if (discreteCoverage.isSetUnit()) {
            monrlt.setUom(discreteCoverage.getUnit());
        } else if (value.isSetUnit()) {
            monrlt.setUom(value.getUnit());
        }
        monrlt.setListValue(list);
        rst.set(qld);
    }
}
Also used : CountListDocument(net.opengis.gml.x32.CountListDocument) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) BooleanListDocument(net.opengis.gml.x32.BooleanListDocument) CoordinatesType(net.opengis.gml.x32.CoordinatesType) CountValue(org.n52.shetland.ogc.om.values.CountValue) TextValue(org.n52.shetland.ogc.om.values.TextValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) DataBlockType(net.opengis.gml.x32.DataBlockType) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument)

Example 30 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractEnvironmentalMonitoringFaciltityEncoder method setRelatedTo.

private void setRelatedTo(EnvironmentalMonitoringFacilityType emft, EnvironmentalMonitoringFacility environmentalMonitoringFacility) throws EncodingException {
    if (environmentalMonitoringFacility.isSetRelatedTo()) {
        for (AnyDomainLink relatedTo : environmentalMonitoringFacility.getRelatedTo()) {
            if (relatedTo.isSetSimpleAttrs()) {
                RelatedTo rt = emft.addNewRelatedTo();
                rt.setHref(relatedTo.getSimpleAttrs().getHref());
                if (relatedTo.getSimpleAttrs().isSetTitle()) {
                    rt.setTitle(relatedTo.getSimpleAttrs().getTitle());
                }
            } else {
                emft.addNewRelatedTo().addNewAnyDomainLink().set(encodeEF(relatedTo));
            }
        }
    }
}
Also used : AnyDomainLink(org.n52.shetland.inspire.ef.AnyDomainLink) RelatedTo(eu.europa.ec.inspire.schemas.ef.x40.EnvironmentalMonitoringFacilityType.RelatedTo)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)124 Test (org.junit.Test)93 EncodingException (org.n52.svalbard.encode.exception.EncodingException)60 SweField (org.n52.shetland.ogc.swe.SweField)29 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)29 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)22 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)21 XmlException (org.apache.xmlbeans.XmlException)20 DateTime (org.joda.time.DateTime)19 OmObservation (org.n52.shetland.ogc.om.OmObservation)19 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)17 Time (org.n52.shetland.ogc.gml.time.Time)15 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)15 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)13 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)13 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)12 SystemType (net.opengis.sensorML.x101.SystemType)11 DataRecordType (net.opengis.swe.x101.DataRecordType)11