Search in sources :

Example 1 with SweQuality

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() };
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweQuality(org.n52.shetland.ogc.swe.simpleType.SweQuality) QualityPropertyType(net.opengis.swe.x101.QualityPropertyType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory)

Example 2 with SweQuality

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;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweQuality(org.n52.shetland.ogc.swe.simpleType.SweQuality) QualityPropertyType(net.opengis.swe.x20.QualityPropertyType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory)

Example 3 with SweQuality

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));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) 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) Test(org.junit.Test)

Example 4 with SweQuality

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));
}
Also used : SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) 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) Test(org.junit.Test)

Example 5 with SweQuality

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

Count (net.opengis.swe.x101.CountDocument.Count)4 XmlObject (org.apache.xmlbeans.XmlObject)4 Test (org.junit.Test)4 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)4 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)3 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)3 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)3 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)3 SweQuality (org.n52.shetland.ogc.swe.simpleType.SweQuality)2 BigDecimal (java.math.BigDecimal)1 QualityPropertyType (net.opengis.swe.x101.QualityPropertyType)1 QualityPropertyType (net.opengis.swe.x20.QualityPropertyType)1 RangeValue (org.n52.shetland.ogc.swe.RangeValue)1