use of org.n52.shetland.ogc.swe.simpleType.SweQuality in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createQuality.
private QualityPropertyType[] createQuality(Collection<SweQuality> quality) {
if (!quality.isEmpty()) {
ArrayList<QualityPropertyType> xbQualities = Lists.newArrayListWithCapacity(quality.size());
for (SweQuality sweQuality : quality) {
QualityPropertyType xbQuality = QualityPropertyType.Factory.newInstance();
if (sweQuality instanceof SweText) {
xbQuality.addNewText().set(createText((SweText) sweQuality));
} else if (sweQuality instanceof SweCategory) {
xbQuality.addNewCategory().set(createCategory((SweCategory) sweQuality));
} else if (sweQuality instanceof SweQuantity) {
xbQuality.addNewQuantity().set(createQuantity((SweQuantity) sweQuality));
} else if (sweQuality instanceof SweQuantityRange) {
xbQuality.addNewQuantityRange().set(createQuantityRange((SweQuantityRange) sweQuality));
}
xbQualities.add(xbQuality);
}
return xbQualities.toArray(new QualityPropertyType[xbQualities.size()]);
}
return new QualityPropertyType[] { QualityPropertyType.Factory.newInstance() };
}
use of org.n52.shetland.ogc.swe.simpleType.SweQuality in project arctic-sea by 52North.
the class SweCommonEncoderv20 method createQuality.
private QualityPropertyType[] createQuality(final Collection<SweQuality> quality) throws EncodingException {
if (!quality.isEmpty()) {
final ArrayList<QualityPropertyType> xbQualities = Lists.newArrayListWithCapacity(quality.size());
for (final SweQuality sweQuality : quality) {
final QualityPropertyType xbQuality = QualityPropertyType.Factory.newInstance();
if (sweQuality instanceof SweText) {
xbQuality.addNewText().set(((SweText) sweQuality).accept(new SweDataComponentVisitorImpl()));
} else if (sweQuality instanceof SweCategory) {
xbQuality.addNewCategory().set(((SweCategory) sweQuality).accept(new SweDataComponentVisitorImpl()));
} else if (sweQuality instanceof SweQuantity) {
xbQuality.addNewQuantity().set(((SweQuantity) sweQuality).accept(new SweDataComponentVisitorImpl()));
} else if (sweQuality instanceof SweQuantityRange) {
xbQuality.addNewQuantityRange().set(((SweQuantityRange) sweQuality).accept(new SweDataComponentVisitorImpl()));
}
xbQualities.add(xbQuality);
}
return xbQualities.toArray(new QualityPropertyType[xbQualities.size()]);
}
final QualityPropertyType[] result = { QualityPropertyType.Factory.newInstance() };
return result;
}
use of org.n52.shetland.ogc.swe.simpleType.SweQuality in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_count_with_quality_Quantity.
@Test
public void should_encode_count_with_quality_Quantity() throws EncodingException {
final double qualityQuantityValue = 42.0;
final SweCount sosCount = (SweCount) new SweCount().setQuality(Lists.newArrayList((SweQuality) new SweQuantity().setValue(qualityQuantityValue)));
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).isSetQuantity(), is(true));
assertThat(xbCount.getQualityArray(0).getQuantity().getValue(), is(qualityQuantityValue));
}
use of org.n52.shetland.ogc.swe.simpleType.SweQuality in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_count_with_quality_Category.
@Test
public void should_encode_count_with_quality_Category() throws EncodingException {
final String qualityCategoryValue = "quality-category-value";
final SweCount sosCount = (SweCount) new SweCount().setQuality(Lists.newArrayList((SweQuality) new SweCategory().setValue(qualityCategoryValue)));
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).isSetCategory(), is(true));
assertThat(xbCount.getQualityArray(0).getCategory().getValue(), is(qualityCategoryValue));
}
use of org.n52.shetland.ogc.swe.simpleType.SweQuality 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