Search in sources :

Example 1 with ReferencableGridCoverage

use of org.n52.shetland.ogc.om.values.ReferencableGridCoverage 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)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)1 ProfileLevel (org.n52.shetland.ogc.om.values.ProfileLevel)1 ProfileValue (org.n52.shetland.ogc.om.values.ProfileValue)1 QuantityRangeValue (org.n52.shetland.ogc.om.values.QuantityRangeValue)1 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)1 RectifiedGridCoverage (org.n52.shetland.ogc.om.values.RectifiedGridCoverage)1 ReferencableGridCoverage (org.n52.shetland.ogc.om.values.ReferencableGridCoverage)1