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));
}
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations