Search in sources :

Example 1 with MeasureOrNilReasonListType

use of net.opengis.gml.x32.MeasureOrNilReasonListType 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 2 with MeasureOrNilReasonListType

use of net.opengis.gml.x32.MeasureOrNilReasonListType in project arctic-sea by 52North.

the class WmlTDREncoderv20 method createMeasurementDomainRange.

/**
 * Create a XML MeasurementTimeseriesDomainRange object from SOS observation
 * for om:result
 *
 * @param sosObservation
 *            SOS observation
 * @return XML MeasurementTimeseriesDomainRange object for om:result
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createMeasurementDomainRange(OmObservation sosObservation) throws EncodingException {
    if (!sosObservation.getObservationConstellation().isSetObservationType() || (sosObservation.getObservationConstellation().isSetObservationType() && isInvalidObservationType(sosObservation.getObservationConstellation().getObservationType()))) {
        throw new UnsupportedEncoderInputException(this, sosObservation.getObservationConstellation().isSetObservationType());
    }
    MeasurementTimeseriesDomainRangeDocument xbMearuementTimeseriesDomainRangeDoc = MeasurementTimeseriesDomainRangeDocument.Factory.newInstance();
    MeasurementTimeseriesCoverageType xbMeasurementTimeseriesDomainRange = xbMearuementTimeseriesDomainRangeDoc.addNewMeasurementTimeseriesDomainRange();
    xbMeasurementTimeseriesDomainRange.setId(TIMESERIES_ID_PREFIX + sosObservation.getObservationID());
    // set time position list
    xbMeasurementTimeseriesDomainRange.addNewDomainSet().set(getTimePositionList(sosObservation));
    // initialize unit
    AbstractPhenomenon observableProperty = sosObservation.getObservationConstellation().getObservableProperty();
    String unit = null;
    // create quantity list from values
    QuantityListDocument quantityListDoc = QuantityListDocument.Factory.newInstance();
    MeasureOrNilReasonListType quantityList = quantityListDoc.addNewQuantityList();
    if (sosObservation.getValue() instanceof MultiObservationValues) {
        MultiObservationValues<?> observationValue = (MultiObservationValues<?>) sosObservation.getValue();
        TVPValue tvpValue = (TVPValue) observationValue.getValue();
        List<TimeValuePair> timeValuePairs = tvpValue.getValue();
        if (Strings.isNullOrEmpty(unit) && CollectionHelper.isNotEmpty(timeValuePairs) && timeValuePairs.get(0).getValue().isSetUnit()) {
            unit = timeValuePairs.get(0).getValue().getUnit();
        }
        quantityList.setListValue(getValueList(timeValuePairs));
    }
    if (Strings.isNullOrEmpty(unit)) {
        unit = OGCConstants.UNKNOWN;
    }
    quantityList.setUom(unit);
    // set unit to SosObservableProperty if not set.
    if (observableProperty instanceof OmObservableProperty && !((OmObservableProperty) observableProperty).isSetUnit()) {
        ((OmObservableProperty) observableProperty).setUnit(unit);
    }
    // set up range set
    xbMeasurementTimeseriesDomainRange.addNewRangeSet().set(quantityListDoc);
    // set up rangeType
    xbMeasurementTimeseriesDomainRange.addNewRangeType().set(createDataRecord(sosObservation));
    // set om:Result
    return xbMearuementTimeseriesDomainRangeDoc;
}
Also used : TVPValue(org.n52.shetland.ogc.om.values.TVPValue) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) MeasurementTimeseriesDomainRangeDocument(net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument) AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument) MeasurementTimeseriesCoverageType(net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Example 3 with MeasureOrNilReasonListType

use of net.opengis.gml.x32.MeasureOrNilReasonListType in project arctic-sea by 52North.

the class WmlTDREncoderv20 method createMeasurementDomainRange.

private XmlObject createMeasurementDomainRange(AbstractObservationValue<?> observationValue) throws EncodingException {
    if (!observationValue.isSetObservationType() || (observationValue.isSetObservationType() && isInvalidObservationType(observationValue.getObservationType()))) {
        return null;
    }
    MeasurementTimeseriesDomainRangeDocument xbMearuementTimeseriesDomainRangeDoc = MeasurementTimeseriesDomainRangeDocument.Factory.newInstance();
    MeasurementTimeseriesCoverageType xbMeasurementTimeseriesDomainRange = xbMearuementTimeseriesDomainRangeDoc.addNewMeasurementTimeseriesDomainRange();
    xbMeasurementTimeseriesDomainRange.setId(TIMESERIES_ID_PREFIX + observationValue.getObservationID());
    // set time position list
    xbMeasurementTimeseriesDomainRange.addNewDomainSet().set(getTimePositionList(observationValue));
    // initialize unit
    // AbstractPhenomenon observableProperty =
    // observationValue.getObservableProperty();
    String unit = null;
    // create quantity list from values
    QuantityListDocument quantityListDoc = QuantityListDocument.Factory.newInstance();
    MeasureOrNilReasonListType quantityList = quantityListDoc.addNewQuantityList();
    if (observationValue instanceof MultiObservationValues) {
        TVPValue tvpValue = (TVPValue) ((MultiObservationValues<?>) observationValue).getValue();
        List<TimeValuePair> timeValuePairs = tvpValue.getValue();
        if (Strings.isNullOrEmpty(unit) && CollectionHelper.isNotEmpty(timeValuePairs) && timeValuePairs.get(0).getValue().isSetUnit()) {
            unit = timeValuePairs.get(0).getValue().getUnit();
        }
        quantityList.setListValue(getValueList(timeValuePairs));
    }
    if (Strings.isNullOrEmpty(unit)) {
        unit = OGCConstants.UNKNOWN;
    }
    quantityList.setUom(unit);
    // set unit to SosObservableProperty if not set.
    // if (observableProperty instanceof OmObservableProperty
    // && !((OmObservableProperty) observableProperty).isSetUnit()) {
    // ((OmObservableProperty) observableProperty).setUnit(unit);
    // }
    // set up range set
    xbMeasurementTimeseriesDomainRange.addNewRangeSet().set(quantityListDoc);
    // set up rangeType
    xbMeasurementTimeseriesDomainRange.addNewRangeType().set(createDataRecord(observationValue, unit));
    // set om:Result
    return xbMearuementTimeseriesDomainRangeDoc;
}
Also used : MeasurementTimeseriesDomainRangeDocument(net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument) MeasurementTimeseriesCoverageType(net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Aggregations

MeasureOrNilReasonListType (net.opengis.gml.x32.MeasureOrNilReasonListType)3 QuantityListDocument (net.opengis.gml.x32.QuantityListDocument)3 MeasurementTimeseriesCoverageType (net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType)2 MeasurementTimeseriesDomainRangeDocument (net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument)2 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)2 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)2 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)2 BooleanListDocument (net.opengis.gml.x32.BooleanListDocument)1 CoordinatesType (net.opengis.gml.x32.CoordinatesType)1 CountListDocument (net.opengis.gml.x32.CountListDocument)1 DataBlockType (net.opengis.gml.x32.DataBlockType)1 AbstractPhenomenon (org.n52.shetland.ogc.om.AbstractPhenomenon)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 BooleanValue (org.n52.shetland.ogc.om.values.BooleanValue)1 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)1 CountValue (org.n52.shetland.ogc.om.values.CountValue)1 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)1 TextValue (org.n52.shetland.ogc.om.values.TextValue)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1