Search in sources :

Example 96 with Value

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;
}
Also used : SweAllowedValues(org.n52.shetland.ogc.swe.simpleType.SweAllowedValues) List(java.util.List) ArrayList(java.util.ArrayList) XmlObject(org.apache.xmlbeans.XmlObject) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 97 with Value

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;
}
Also used : SweAllowedValues(org.n52.shetland.ogc.swe.simpleType.SweAllowedValues) List(java.util.List) ArrayList(java.util.ArrayList) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 98 with Value

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;
}
Also used : SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 99 with Value

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;
}
Also used : CountValue(org.n52.shetland.ogc.om.values.CountValue) MeasurementTimeLocationValueTripleType(eu.europa.ec.inspire.schemas.omso.x30.MeasurementTimeLocationValueTripleType) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue)

Example 100 with Value

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!");
        }
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5