Search in sources :

Example 1 with RectifiedGridCoverage

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

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

the class RectifiedGridCoverageDocumentEncoderTest method getRectifiedGridCoverage.

private RectifiedGridCoverage getRectifiedGridCoverage() {
    RectifiedGridCoverage rgc = new RectifiedGridCoverage("quantity");
    rgc.addValue(new QuantityValue(2.5, "m"), new QuantityValue(10.0));
    rgc.addValue(new QuantityValue(5.0, "m"), new QuantityValue(8.0));
    rgc.addValue(new QuantityValue(10.0, "m"), new QuantityValue(3.0));
    rgc.setUnit("C");
    return rgc;
}
Also used : QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) RectifiedGridCoverage(org.n52.shetland.ogc.om.values.RectifiedGridCoverage)

Example 3 with RectifiedGridCoverage

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

the class AbstractRectifiedGridCoverageTypeEncoder method encodeDomainSet.

private XmlObject encodeDomainSet(RectifiedGridCoverage rectifiedGridCoverage) {
    List<ComparableValue<?, ?>> domainSet = rectifiedGridCoverage.getDomainSet();
    if (!checkForRange(domainSet)) {
        SimpleMultiPointDocument smpd = SimpleMultiPointDocument.Factory.newInstance();
        SimpleMultiPointType smpt = smpd.addNewSimpleMultiPoint();
        smpt.setId("smp_" + rectifiedGridCoverage.getGmlId());
        DirectPositionListType dplt = smpt.addNewPosList();
        List<String> uoms = getUoms(domainSet);
        if (!uoms.isEmpty()) {
            dplt.setUomLabels(Lists.newArrayList(uoms));
        }
        dplt.setListValue(getList(rectifiedGridCoverage.getDomainSet()));
        return smpd;
    } else {
        LineStringDocument lsd = LineStringDocument.Factory.newInstance();
        LineStringType lst = lsd.addNewLineString();
        lst.setId("ls_" + rectifiedGridCoverage.getGmlId());
        lst.setUomLabels(getUoms(domainSet));
        for (ComparableValue<?, ?> quantityValued : domainSet) {
            Object value = quantityValued.getValue();
            if (value instanceof Double) {
                lst.addNewPos().setListValue(Lists.newArrayList((Double) value));
            } else if (value instanceof RangeValue) {
                lst.addNewPos().setListValue(((RangeValue) value).getRangeAsList());
            }
        }
        return lsd;
    }
}
Also used : SimpleMultiPointType(net.opengis.gml.x33.ce.SimpleMultiPointType) DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) LineStringType(net.opengis.gml.x32.LineStringType) ComparableValue(org.n52.shetland.ogc.om.values.ComparableValue) RangeValue(org.n52.shetland.ogc.swe.RangeValue) SimpleMultiPointDocument(net.opengis.gml.x33.ce.SimpleMultiPointDocument) LineStringDocument(net.opengis.gml.x32.LineStringDocument) XmlObject(org.apache.xmlbeans.XmlObject)

Example 4 with RectifiedGridCoverage

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

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

RectifiedGridCoverage (org.n52.shetland.ogc.om.values.RectifiedGridCoverage)4 QuantityRangeValue (org.n52.shetland.ogc.om.values.QuantityRangeValue)3 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)2 DirectPositionListType (net.opengis.gml.x32.DirectPositionListType)1 LineStringDocument (net.opengis.gml.x32.LineStringDocument)1 LineStringType (net.opengis.gml.x32.LineStringType)1 SimpleMultiPointDocument (net.opengis.gml.x33.ce.SimpleMultiPointDocument)1 SimpleMultiPointType (net.opengis.gml.x33.ce.SimpleMultiPointType)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)1 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)1 ComparableValue (org.n52.shetland.ogc.om.values.ComparableValue)1 ProfileLevel (org.n52.shetland.ogc.om.values.ProfileLevel)1 ProfileValue (org.n52.shetland.ogc.om.values.ProfileValue)1 ReferencableGridCoverage (org.n52.shetland.ogc.om.values.ReferencableGridCoverage)1 TextValue (org.n52.shetland.ogc.om.values.TextValue)1 RangeValue (org.n52.shetland.ogc.swe.RangeValue)1