Search in sources :

Example 16 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class DefaultElasticsearchSchemas method resolveParameterField.

private void resolveParameterField(AbstractEsParameter value, Map<String, Object> map) {
    if (value instanceof SingleEsParameter) {
        SingleEsParameter single = (SingleEsParameter) value;
        map.put(single.getName(), single.getTypeAsMap());
    } else if (value instanceof ObjectEsParameter) {
        ObjectEsParameter object = (ObjectEsParameter) value;
        // loadup all the children
        // the wrapper properties map is needed to elasticsearch
        Map<String, Object> subproperties = new HashMap<>(1);
        Map<String, Object> childrenMap = new HashMap<>(value.getAllChildren().size());
        subproperties.put(PROPERTIES_KEY, childrenMap);
        for (AbstractEsParameter child : object.getAllChildren()) {
            resolveParameterField(child, childrenMap);
        }
        map.put(object.getName(), subproperties);
    } else {
        throw new IllegalArgumentException("Invalid schema parameter value " + value.toString());
    }
}
Also used : ObjectEsParameter(org.n52.iceland.statistics.api.parameters.ObjectEsParameter) AbstractEsParameter(org.n52.iceland.statistics.api.parameters.AbstractEsParameter) SingleEsParameter(org.n52.iceland.statistics.api.parameters.SingleEsParameter) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class AbstractPropertyFileHandler method save.

public void save(String m, String value) throws ConfigurationError {
    lock.writeLock().lock();
    try {
        Properties p = load();
        p.setProperty(m, value);
        save(p);
    } catch (IOException e) {
        throw new ConfigurationError(ERROR_WRITING_MESSAGE, e);
    } finally {
        lock.writeLock().unlock();
    }
}
Also used : ConfigurationError(org.n52.faroe.ConfigurationError) IOException(java.io.IOException) Properties(java.util.Properties)

Example 18 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class ProfileObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof RectifiedGridCoverage || value.getValue() instanceof ReferencableGridCoverage) {
        super.setValue(value);
    } else if (value.getValue() instanceof ProfileValue) {
        ProfileValue profile = (ProfileValue) value.getValue();
        RectifiedGridCoverage rectifiedGridCoverage = new RectifiedGridCoverage(getObservationID());
        rectifiedGridCoverage.setUnit(value.getValue().getUnit());
        rectifiedGridCoverage.setRangeParameters(getObservationConstellation().getObservablePropertyIdentifier());
        List<Coordinate> coordinates = Lists.newArrayList();
        int srid = 0;
        for (ProfileLevel level : profile.getValue()) {
            if (level.isSetLevelEnd()) {
                rectifiedGridCoverage.addValue(new QuantityRangeValue(level.getLevelStart().getValue(), level.getLevelEnd().getValue(), level.getLevelStart().getUnit()), level.getSimpleValue());
            } else {
                rectifiedGridCoverage.addValue(level.getLevelStart(), level.getSimpleValue());
            }
            if (level.isSetLocation()) {
                Coordinate coordinate = level.getLocation().getCoordinate();
                coordinate.z = level.getLevelStart().getValue().doubleValue();
                coordinates.add(coordinate);
                if (srid == 0) {
                    srid = level.getLocation().getSRID();
                }
            }
        }
        if (CollectionHelper.isNotEmpty(coordinates)) {
            setFeatureGeometry(coordinates, srid);
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), rectifiedGridCoverage));
    } else {
        QuantityValue heightDepth = new QuantityValue(0.0);
        if (isSetHeightDepthParameter()) {
            heightDepth = (QuantityValue) getHeightDepthParameter().getValue();
            removeParameter(getHeightDepthParameter());
        }
        RectifiedGridCoverage rectifiedGridCoverage = new RectifiedGridCoverage(getObservationID());
        rectifiedGridCoverage.setUnit(value.getValue().getUnit());
        rectifiedGridCoverage.addValue(heightDepth, value.getValue());
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), rectifiedGridCoverage));
    }
}
Also used : StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Coordinate(org.locationtech.jts.geom.Coordinate) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel) QuantityRangeValue(org.n52.shetland.ogc.om.values.QuantityRangeValue) RectifiedGridCoverage(org.n52.shetland.ogc.om.values.RectifiedGridCoverage) ReferencableGridCoverage(org.n52.shetland.ogc.om.values.ReferencableGridCoverage) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue)

Example 19 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class TrajectoryObservation method convertSingleValueToMultiValue.

/**
 * Convert {@link SingleObservationValue} to {@link TVPValue}
 *
 * @param singleValue
 *            Single observation value
 * @return Converted TVPValue value
 */
private TLVTValue convertSingleValueToMultiValue(final SingleObservationValue<?> singleValue, Geometry geom) {
    final TLVTValue tlvpValue = new TLVTValue();
    tlvpValue.setUnit(singleValue.getValue().getUnit());
    final TimeLocationValueTriple timeLocationValueTriple = new TimeLocationValueTriple(singleValue.getPhenomenonTime(), singleValue.getValue(), geom);
    tlvpValue.addValue(timeLocationValueTriple);
    return tlvpValue;
}
Also used : TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 20 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class TrajectoryObservation method setValue.

@SuppressWarnings("rawtypes")
@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue || value.getValue() instanceof TLVTValue) {
        super.setValue(value);
    } else {
        Geometry geometry = null;
        if (isSetSpatialFilteringProfileParameter()) {
            geometry = getSpatialFilteringProfileParameter().getValue().getValue();
        } else {
            if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
                geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
            }
        }
        TLVTValue tlvpValue = convertSingleValueToMultiValue((SingleObservationValue<?>) value, geometry);
        if (!tlvpValue.isSetUnit() && ((AbstractObservationValue<?>) value).isSetUnit()) {
            tlvpValue.setUnit(((AbstractObservationValue<?>) value).getUnit());
        }
        final MultiObservationValues<List<TimeLocationValueTriple>> multiValue = new MultiObservationValues<List<TimeLocationValueTriple>>();
        multiValue.setValue(tlvpValue);
        if (!multiValue.isSetObservationID()) {
            if (value instanceof AbstractObservationValue && ((AbstractObservationValue) value).isSetObservationID()) {
                multiValue.setObservationID(((AbstractObservationValue) value).getObservationID());
            } else if (isSetObservationID()) {
                multiValue.setObservationID(getObservationID());
            }
        }
        super.setValue(multiValue);
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) AbstractObservationValue(org.n52.shetland.ogc.om.AbstractObservationValue) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) List(java.util.List) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

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