Search in sources :

Example 1 with SweAllowedValues

use of org.n52.shetland.ogc.swe.simpleType.SweAllowedValues in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseAllowedValues.

@SuppressWarnings({ "unchecked", "rawtypes" })
private SweAllowedValues parseAllowedValues(AllowedValues avt) {
    SweAllowedValues allowedValues = new SweAllowedValues();
    if (avt.isSetId()) {
        allowedValues.setGmlId(avt.getId());
    }
    if (CollectionHelper.isNotNullOrEmpty(avt.getValueListArray())) {
        for (List list : avt.getValueListArray()) {
            if (CollectionHelper.isNotEmpty(list)) {
                for (Object value : list) {
                    allowedValues.addValue(Double.parseDouble(value.toString()));
                }
            }
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(avt.getIntervalArray())) {
        for (List interval : avt.getIntervalArray()) {
            RangeValue<Double> rangeValue = new RangeValue<Double>();
            Iterator<Double> iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(iterator.next());
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(iterator.next());
            }
            allowedValues.addInterval(rangeValue);
        }
    }
    return allowedValues;
}
Also used : SweAllowedValues(org.n52.shetland.ogc.swe.simpleType.SweAllowedValues) List(java.util.List) ArrayList(java.util.ArrayList) XmlObject(org.apache.xmlbeans.XmlObject) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 2 with SweAllowedValues

use of org.n52.shetland.ogc.swe.simpleType.SweAllowedValues in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseAllowedValues.

@SuppressWarnings({ "rawtypes", "unchecked" })
private SweAllowedValues parseAllowedValues(AllowedValuesType avt) {
    SweAllowedValues allowedValues = new SweAllowedValues();
    if (avt.isSetId()) {
        allowedValues.setGmlId(avt.getId());
    }
    if (avt.getValueArray() != null && avt.getValueArray().length > 0) {
        for (double value : avt.getValueArray()) {
            allowedValues.addValue(value);
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(avt.getIntervalArray())) {
        for (List interval : avt.getIntervalArray()) {
            RangeValue<Double> rangeValue = new RangeValue<Double>();
            Iterator<Double> iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(iterator.next());
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(iterator.next());
            }
            allowedValues.addInterval(rangeValue);
        }
    }
    if (avt.isSetSignificantFigures()) {
        allowedValues.setSignificantFigures(avt.getSignificantFigures());
    }
    return allowedValues;
}
Also used : SweAllowedValues(org.n52.shetland.ogc.swe.simpleType.SweAllowedValues) List(java.util.List) ArrayList(java.util.ArrayList) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 RangeValue (org.n52.shetland.ogc.swe.RangeValue)2 SweAllowedValues (org.n52.shetland.ogc.swe.simpleType.SweAllowedValues)2 XmlObject (org.apache.xmlbeans.XmlObject)1