Search in sources :

Example 11 with RangeValue

use of org.n52.shetland.ogc.swe.RangeValue 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 12 with RangeValue

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

Example 13 with RangeValue

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

the class SweCommonDecoderV20 method parseTimeRange.

private SweTimeRange parseTimeRange(TimeRangeType xbTime) throws DecodingException {
    SweTimeRange sosTimeRange = new SweTimeRange();
    if (xbTime.isSetValue()) {
        List<?> value = xbTime.getValue();
        if (value != null && !value.isEmpty()) {
            RangeValue<DateTime> range = new RangeValue<>();
            Iterator<?> iter = value.iterator();
            if (iter.hasNext()) {
                range.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
            }
            if (iter.hasNext()) {
                range.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
            }
            sosTimeRange.setValue(range);
        }
    }
    if (xbTime.getUom() != null) {
        sosTimeRange.setUom(xbTime.getUom().getHref());
    }
    if (xbTime.isSetConstraint()) {
        sosTimeRange.setConstraint(parseConstraint(xbTime.getConstraint()));
    }
    if (xbTime.getQualityArray() != null) {
        sosTimeRange.setQuality(parseQuality(xbTime.getQualityArray()));
    }
    return sosTimeRange;
}
Also used : SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 14 with RangeValue

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

the class AbstractRectifiedGridCoverageTypeEncoder method encodeDomainSet.

private XmlObject encodeDomainSet(RectifiedGridCoverage rectifiedGridCoverage) {
    List<ComparableValue<?, ?>> domainSet = rectifiedGridCoverage.getDomainSet();
    if (!checkForRange(domainSet)) {
        SimpleMultiPointDocument smpd = SimpleMultiPointDocument.Factory.newInstance();
        SimpleMultiPointType smpt = smpd.addNewSimpleMultiPoint();
        smpt.setId("smp_" + rectifiedGridCoverage.getGmlId());
        DirectPositionListType dplt = smpt.addNewPosList();
        List<String> uoms = getUoms(domainSet);
        if (!uoms.isEmpty()) {
            dplt.setUomLabels(Lists.newArrayList(uoms));
        }
        dplt.setListValue(getList(rectifiedGridCoverage.getDomainSet()));
        return smpd;
    } else {
        LineStringDocument lsd = LineStringDocument.Factory.newInstance();
        LineStringType lst = lsd.addNewLineString();
        lst.setId("ls_" + rectifiedGridCoverage.getGmlId());
        lst.setUomLabels(getUoms(domainSet));
        for (ComparableValue<?, ?> quantityValued : domainSet) {
            Object value = quantityValued.getValue();
            if (value instanceof Double) {
                lst.addNewPos().setListValue(Lists.newArrayList((Double) value));
            } else if (value instanceof RangeValue) {
                lst.addNewPos().setListValue(((RangeValue) value).getRangeAsList());
            }
        }
        return lsd;
    }
}
Also used : SimpleMultiPointType(net.opengis.gml.x33.ce.SimpleMultiPointType) DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) LineStringType(net.opengis.gml.x32.LineStringType) ComparableValue(org.n52.shetland.ogc.om.values.ComparableValue) RangeValue(org.n52.shetland.ogc.swe.RangeValue) SimpleMultiPointDocument(net.opengis.gml.x33.ce.SimpleMultiPointDocument) LineStringDocument(net.opengis.gml.x32.LineStringDocument) XmlObject(org.apache.xmlbeans.XmlObject)

Example 15 with RangeValue

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

the class SweCommonEncoderv101Test method should_encode_count_with_quality_QuantityRange.

@Test
public void should_encode_count_with_quality_QuantityRange() throws EncodingException {
    final RangeValue<BigDecimal> qualityQuantityRangeValue = new RangeValue<>(BigDecimal.valueOf(1.0), BigDecimal.valueOf(2.0));
    final SweCount sosCount = (SweCount) new SweCount().setQuality(Lists.newArrayList((SweQuality) new SweQuantityRange().setValue(qualityQuantityRangeValue)));
    final XmlObject encode = sweCommonEncoderv101.encode(sosCount);
    assertThat(encode, instanceOf(Count.class));
    final Count xbCount = (Count) encode;
    assertThat(xbCount.getQualityArray(), is(not(nullValue())));
    assertThat(xbCount.getQualityArray().length, is(1));
    assertThat(xbCount.getQualityArray(0).isSetQuantityRange(), is(true));
    assertThat(BigDecimal.valueOf((Double) xbCount.getQualityArray(0).getQuantityRange().getValue().get(0)), is(qualityQuantityRangeValue.getRangeStart()));
    assertThat(BigDecimal.valueOf((Double) xbCount.getQualityArray(0).getQuantityRange().getValue().get(1)), is(qualityQuantityRangeValue.getRangeEnd()));
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Count(net.opengis.swe.x101.CountDocument.Count) BigDecimal(java.math.BigDecimal) RangeValue(org.n52.shetland.ogc.swe.RangeValue) Test(org.junit.Test)

Aggregations

RangeValue (org.n52.shetland.ogc.swe.RangeValue)10 XmlObject (org.apache.xmlbeans.XmlObject)6 DateTime (org.joda.time.DateTime)6 BigDecimal (java.math.BigDecimal)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)4 Test (org.junit.Test)3 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)3 Iterator (java.util.Iterator)2 SweAllowedTimes (org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes)2 SweAllowedValues (org.n52.shetland.ogc.swe.simpleType.SweAllowedValues)2 SweCountRange (org.n52.shetland.ogc.swe.simpleType.SweCountRange)2 DirectPositionListType (net.opengis.gml.x32.DirectPositionListType)1 LineStringDocument (net.opengis.gml.x32.LineStringDocument)1 LineStringType (net.opengis.gml.x32.LineStringType)1 SimpleMultiPointDocument (net.opengis.gml.x33.ce.SimpleMultiPointDocument)1 SimpleMultiPointType (net.opengis.gml.x33.ce.SimpleMultiPointType)1 CategoryDocument (net.opengis.swe.x101.CategoryDocument)1 Count (net.opengis.swe.x101.CountDocument.Count)1