Search in sources :

Example 1 with CvDiscretePointCoverage

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

the class PointObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof CvDiscretePointCoverage) {
        super.setValue(value);
    } else {
        CvDiscretePointCoverage cvDiscretePointCoverage = new CvDiscretePointCoverage(getObservationID());
        cvDiscretePointCoverage.setRangeType(new ReferenceType(getObservationConstellation().getObservablePropertyIdentifier()));
        cvDiscretePointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
        Geometry geometry = null;
        String domainExtent = "";
        if (isSetSpatialFilteringProfileParameter() && getSpatialFilteringProfileParameter().getValue() instanceof GeometryValue) {
            GeometryValue geometryValue = (GeometryValue) getSpatialFilteringProfileParameter().getValue();
            geometry = getSpatialFilteringProfileParameter().getValue().getValue();
            domainExtent = geometryValue.getGmlId();
        } else if (checkForFeatureGeometry(this)) {
            geometry = getGeometryFromFeature(this);
            domainExtent = getObservationConstellation().getFeatureOfInterest().getGmlId();
        }
        if (geometry != null) {
            cvDiscretePointCoverage.setDomainExtent("#" + geometry.getGeometryType() + "_" + domainExtent);
            Point point = null;
            if (geometry instanceof Point) {
                point = (Point) geometry;
            } else {
                point = geometry.getCentroid();
            }
            cvDiscretePointCoverage.setValue(new PointValuePair(point, value.getValue()));
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), cvDiscretePointCoverage));
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) CvDiscretePointCoverage(org.n52.shetland.ogc.om.values.CvDiscretePointCoverage) AbstractObservationValue(org.n52.shetland.ogc.om.AbstractObservationValue) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Point(org.locationtech.jts.geom.Point) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Aggregations

Geometry (org.locationtech.jts.geom.Geometry)1 Point (org.locationtech.jts.geom.Point)1 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)1 AbstractObservationValue (org.n52.shetland.ogc.om.AbstractObservationValue)1 PointValuePair (org.n52.shetland.ogc.om.PointValuePair)1 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)1 CvDiscretePointCoverage (org.n52.shetland.ogc.om.values.CvDiscretePointCoverage)1 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)1