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;
}
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;
}
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;
}
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;
}
}
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()));
}
Aggregations