Search in sources :

Example 1 with ProfileLevel

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

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

the class ProfileValue method getGeometry.

public Geometry getGeometry() {
    if (isSetGeometry()) {
        TreeMap<Time, Coordinate> map = new TreeMap<>();
        int srid = -1;
        for (ProfileLevel level : getValue()) {
            if (level.isSetPhenomenonTime() && level.isSetLocation()) {
                if (srid < 0) {
                    srid = level.getLocation().getSRID();
                }
                map.put(level.getPhenomenonTime(), level.getLocation().getCoordinate());
            }
        }
        if (!map.isEmpty()) {
            if (new HashSet<>(map.values()).size() == 1) {
                return getValue().iterator().next().getLocation();
            } else {
                return new GeometryFactory(new PrecisionModel(), srid).createLineString(map.values().toArray(new Coordinate[1]));
            }
        }
    }
    return null;
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) Time(org.n52.shetland.ogc.gml.time.Time) PrecisionModel(org.locationtech.jts.geom.PrecisionModel) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Example 3 with ProfileLevel

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

the class ProfileValueTest method createProfileLevel.

private ProfileLevel createProfileLevel(boolean fromDepth, boolean toDepth, double start) {
    ProfileLevel profileLevel = new ProfileLevel();
    if (fromDepth) {
        profileLevel.setLevelStart(createQuantity("fromDepth", start, "m"));
    }
    if (toDepth) {
        profileLevel.setLevelEnd(createQuantity("toDepth", start + 10.0, "m"));
    }
    profileLevel.setValue(createProfileLevel());
    return profileLevel;
}
Also used : ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel)

Example 4 with ProfileLevel

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

the class GWGeologyLogCoveragePropertyEncoderTest method createLogValue.

private ProfileLevel createLogValue(boolean fromDepth, boolean toDepth, double start) {
    ProfileLevel profileLevel = new ProfileLevel();
    if (fromDepth) {
        profileLevel.setLevelStart(createQuantity("fromDepth", start, "m"));
    }
    if (toDepth) {
        profileLevel.setLevelEnd(createQuantity("toDepth", start + 10.0, "m"));
    }
    profileLevel.setValue(createProfileLevel());
    return profileLevel;
}
Also used : ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel)

Example 5 with ProfileLevel

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

the class ProfileValue method asDataRecord.

public SweDataRecord asDataRecord() {
    SweDataRecord dataRecord = new SweDataRecord();
    if (isSetIdentifier()) {
        dataRecord.setIdentifier(getIdentifier());
    }
    if (isSetName()) {
        dataRecord.setName(getName());
    }
    if (isSetDescription()) {
        dataRecord.setDescription(getDescription());
    }
    int counter = 0;
    for (ProfileLevel level : getValue()) {
        dataRecord.addField(new SweField("level_" + counter++, level.asDataRecord()));
    }
    return dataRecord;
}
Also used : SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField)

Aggregations

ProfileLevel (org.n52.shetland.ogc.om.values.ProfileLevel)3 Coordinate (org.locationtech.jts.geom.Coordinate)2 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 PrecisionModel (org.locationtech.jts.geom.PrecisionModel)1 Time (org.n52.shetland.ogc.gml.time.Time)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)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 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweField (org.n52.shetland.ogc.swe.SweField)1