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