Search in sources :

Example 1 with RangeValue

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

the class FieldDecoder method decodeQuantityRange.

protected SweAbstractDataComponent decodeQuantityRange(JsonNode node) {
    SweQuantityRange swe = new SweQuantityRange();
    if (node.hasNonNull(JSONConstants.VALUE)) {
        BigDecimal start = BigDecimal.valueOf(node.path(JSONConstants.VALUE).path(0).doubleValue());
        BigDecimal end = BigDecimal.valueOf(node.path(JSONConstants.VALUE).path(1).doubleValue());
        swe.setValue(new RangeValue<BigDecimal>(start, end));
    }
    return swe.setUom(node.path(JSONConstants.UOM).textValue());
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) BigDecimal(java.math.BigDecimal)

Example 2 with RangeValue

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

the class FieldDecoder method decodeTimeRange.

protected SweAbstractDataComponent decodeTimeRange(JsonNode node) throws DecodingException {
    SweTimeRange swe = new SweTimeRange();
    if (node.hasNonNull(JSONConstants.VALUE)) {
        String start = node.path(JSONConstants.VALUE).path(0).textValue();
        String end = node.path(JSONConstants.VALUE).path(1).textValue();
        swe.setValue(new RangeValue<DateTime>(parseDateTime(start), parseDateTime(end)));
    }
    return swe.setUom(node.path(JSONConstants.UOM).textValue());
}
Also used : SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime)

Example 3 with RangeValue

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

the class SweCommonDecoderV101 method parseQuantityRange.

private SweQuantityRange parseQuantityRange(QuantityRange xbQuantityRange) throws DecodingException {
    SweQuantityRange sosQuantityRange = new SweQuantityRange();
    if (xbQuantityRange.isSetAxisID()) {
        sosQuantityRange.setAxisID(xbQuantityRange.getAxisID());
    }
    if (xbQuantityRange.isSetDefinition()) {
        sosQuantityRange.setDefinition(xbQuantityRange.getDefinition());
    }
    if (xbQuantityRange.isSetDescription()) {
        sosQuantityRange.setDescription(xbQuantityRange.getDescription().getStringValue());
    }
    if (xbQuantityRange.isSetUom() && xbQuantityRange.getUom().isSetCode()) {
        sosQuantityRange.setUom(xbQuantityRange.getUom().getCode());
    }
    if (xbQuantityRange.isSetValue()) {
        try {
            List<?> value = xbQuantityRange.getValue();
            BigDecimal rangeStart = new BigDecimal(value.get(0).toString());
            BigDecimal rangeEnd = new BigDecimal(value.get(1).toString());
            sosQuantityRange.setValue(new RangeValue<>(rangeStart, rangeEnd));
        } catch (final NumberFormatException | NullPointerException | IndexOutOfBoundsException nfe) {
            throw createParsingException(nfe);
        }
    }
    if (xbQuantityRange.isSetConstraint()) {
        LOGGER.error("Decoding of swe:QuantityRange/swe:constraint is not implemented");
    }
    if (xbQuantityRange.getQualityArray() != null && xbQuantityRange.getQualityArray().length > 0) {
        LOGGER.error("Decoding of swe:QuantityRange/swe:quality is not implemented");
    }
    return sosQuantityRange;
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) BigDecimal(java.math.BigDecimal)

Example 4 with RangeValue

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

the class SweCommonDecoderV101 method parseTimeRange.

private SweTimeRange parseTimeRange(TimeRange timeRange) throws DecodingException {
    SweTimeRange sosTimeRange = new SweTimeRange();
    if (timeRange.isSetValue()) {
        RangeValue<DateTime> range = new RangeValue<>();
        Iterator<?> iter = timeRange.getValue().iterator();
        if (iter.hasNext()) {
            range.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
            while (iter.hasNext()) {
                range.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
            }
        }
        sosTimeRange.setValue(range);
    }
    if (timeRange.getUom() != null) {
        sosTimeRange.setUom(timeRange.getUom().getHref());
    }
    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 5 with RangeValue

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

the class SweCommonDecoderV101 method parseAllowedTimes.

@SuppressWarnings({ "unchecked", "rawtypes" })
private SweAllowedTimes parseAllowedTimes(AllowedTimes att) throws DateTimeParseException {
    SweAllowedTimes allowedTimes = new SweAllowedTimes();
    if (att.isSetId()) {
        allowedTimes.setGmlId(att.getId());
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getValueListArray())) {
        for (List list : att.getValueListArray()) {
            if (CollectionHelper.isNotEmpty(list)) {
                for (Object value : list) {
                    allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
                }
            }
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
        for (List interval : att.getIntervalArray()) {
            RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
            Iterator iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            allowedTimes.addInterval(rangeValue);
        }
    }
    return allowedTimes;
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) XmlObject(org.apache.xmlbeans.XmlObject) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

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