use of org.n52.shetland.ogc.om.values.Value 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.om.values.Value 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.om.values.Value 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.om.values.Value in project arctic-sea by 52North.
the class AbstractTimeLocationValueTripleTypeEncoder method createMeasurementTimeLocationValueTripleType.
/**
* Create a {@link MeasurementTimeLocationValueTripleType} from
* {@link TimeLocationValueTriple}
*
* @param timeLocationValueTriple
* The {@link TimeLocationValueTriple} to encode
* @return The encoded {@link TimeLocationValueTriple}
* @throws EncodingException
* If an error occurs
*/
private TimeValuePairType createMeasurementTimeLocationValueTripleType(TimeLocationValueTriple timeLocationValueTriple) throws EncodingException {
MeasurementTimeLocationValueTripleType mtlvtt = MeasurementTimeLocationValueTripleType.Factory.newInstance();
mtlvtt.addNewTime().setStringValue(getTimeString(timeLocationValueTriple.getTime()));
mtlvtt.addNewLocation().addNewPoint().set(encodeGML(timeLocationValueTriple.getLocation()));
String value = null;
if (timeLocationValueTriple.getValue() instanceof QuantityValue) {
QuantityValue quantityValue = (QuantityValue) timeLocationValueTriple.getValue();
if (quantityValue.isSetValue()) {
value = quantityValue.getValue().toPlainString();
}
} else if (timeLocationValueTriple.getValue() instanceof CountValue) {
CountValue countValue = (CountValue) timeLocationValueTriple.getValue();
if (countValue.getValue() != null) {
value = Integer.toString(countValue.getValue().intValue());
}
}
if (value != null && !value.isEmpty()) {
mtlvtt.addNewValue().setStringValue(value);
} else {
mtlvtt.addNewValue().setNil();
mtlvtt.addNewMetadata().addNewTVPMeasurementMetadata().addNewNilReason().setNilReason(MISSING);
}
return mtlvtt;
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method checkAndAddIdentifier.
private void checkAndAddIdentifier(ObservationProcess op, ObservationProcessType opt) throws EncodingException {
if (op.isSetIdentifier() && !opt.isSetIdentifier()) {
CodeWithAuthority codeWithAuthority = op.getIdentifierCodeWithAuthority();
Encoder<?, CodeWithAuthority> encoder = getEncoder(getEncoderKey(GmlConstants.NS_GML_32, codeWithAuthority));
if (encoder != null) {
XmlObject xmlObject = (XmlObject) encoder.encode(codeWithAuthority);
opt.addNewIdentifier().set(xmlObject);
} else {
throw new EncodingException("Error while encoding geometry value, needed encoder is missing!");
}
}
}
Aggregations