Search in sources :

Example 1 with QuantityRangeValue

use of org.n52.shetland.ogc.om.values.QuantityRangeValue 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 2 with QuantityRangeValue

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

the class RectifiedGridCoverageDocumentEncoderTest method getTextRectifiedGridCoverage.

private RectifiedGridCoverage getTextRectifiedGridCoverage() {
    RectifiedGridCoverage rgc = new RectifiedGridCoverage("text");
    rgc.setUnit("d");
    rgc.setRangeParameters("text_param");
    rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(0.0), BigDecimal.valueOf(5.0), "m"), new TextValue("test text"));
    rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(5.0), BigDecimal.valueOf(10.0), "m"), new TextValue("test text 2"));
    rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(10.0), BigDecimal.valueOf(15.0), "m"), new TextValue("test text 2 test"));
    return rgc;
}
Also used : TextValue(org.n52.shetland.ogc.om.values.TextValue) QuantityRangeValue(org.n52.shetland.ogc.om.values.QuantityRangeValue) RectifiedGridCoverage(org.n52.shetland.ogc.om.values.RectifiedGridCoverage)

Example 3 with QuantityRangeValue

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

the class RectifiedGridCoverageDocumentEncoderTest method getCategoryRectifiedGridCoverage.

private RectifiedGridCoverage getCategoryRectifiedGridCoverage() {
    RectifiedGridCoverage rgc = new RectifiedGridCoverage("category");
    rgc.setUnit("d");
    rgc.setRangeParameters("category_param");
    rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(0.0), BigDecimal.valueOf(5.0), "m"), new CategoryValue("test category"));
    rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(5.0), BigDecimal.valueOf(10.0), "m"), new CategoryValue("test category 2"));
    rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(10.0), BigDecimal.valueOf(15.0), "m"), new CategoryValue("test category 2 test"));
    return rgc;
}
Also used : QuantityRangeValue(org.n52.shetland.ogc.om.values.QuantityRangeValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) RectifiedGridCoverage(org.n52.shetland.ogc.om.values.RectifiedGridCoverage)

Aggregations

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