use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class DefaultElasticsearchSchemas method resolveParameterField.
private void resolveParameterField(AbstractEsParameter value, Map<String, Object> map) {
if (value instanceof SingleEsParameter) {
SingleEsParameter single = (SingleEsParameter) value;
map.put(single.getName(), single.getTypeAsMap());
} else if (value instanceof ObjectEsParameter) {
ObjectEsParameter object = (ObjectEsParameter) value;
// loadup all the children
// the wrapper properties map is needed to elasticsearch
Map<String, Object> subproperties = new HashMap<>(1);
Map<String, Object> childrenMap = new HashMap<>(value.getAllChildren().size());
subproperties.put(PROPERTIES_KEY, childrenMap);
for (AbstractEsParameter child : object.getAllChildren()) {
resolveParameterField(child, childrenMap);
}
map.put(object.getName(), subproperties);
} else {
throw new IllegalArgumentException("Invalid schema parameter value " + value.toString());
}
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class AbstractPropertyFileHandler method save.
public void save(String m, String value) throws ConfigurationError {
lock.writeLock().lock();
try {
Properties p = load();
p.setProperty(m, value);
save(p);
} catch (IOException e) {
throw new ConfigurationError(ERROR_WRITING_MESSAGE, e);
} finally {
lock.writeLock().unlock();
}
}
use of org.n52.shetland.ogc.om.values.Value 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.Value in project arctic-sea by 52North.
the class TrajectoryObservation method convertSingleValueToMultiValue.
/**
* Convert {@link SingleObservationValue} to {@link TVPValue}
*
* @param singleValue
* Single observation value
* @return Converted TVPValue value
*/
private TLVTValue convertSingleValueToMultiValue(final SingleObservationValue<?> singleValue, Geometry geom) {
final TLVTValue tlvpValue = new TLVTValue();
tlvpValue.setUnit(singleValue.getValue().getUnit());
final TimeLocationValueTriple timeLocationValueTriple = new TimeLocationValueTriple(singleValue.getPhenomenonTime(), singleValue.getValue(), geom);
tlvpValue.addValue(timeLocationValueTriple);
return tlvpValue;
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class TrajectoryObservation method setValue.
@SuppressWarnings("rawtypes")
@Override
public void setValue(ObservationValue<?> value) {
if (value instanceof StreamingValue || value.getValue() instanceof TLVTValue) {
super.setValue(value);
} else {
Geometry geometry = null;
if (isSetSpatialFilteringProfileParameter()) {
geometry = getSpatialFilteringProfileParameter().getValue().getValue();
} else {
if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
}
}
TLVTValue tlvpValue = convertSingleValueToMultiValue((SingleObservationValue<?>) value, geometry);
if (!tlvpValue.isSetUnit() && ((AbstractObservationValue<?>) value).isSetUnit()) {
tlvpValue.setUnit(((AbstractObservationValue<?>) value).getUnit());
}
final MultiObservationValues<List<TimeLocationValueTriple>> multiValue = new MultiObservationValues<List<TimeLocationValueTriple>>();
multiValue.setValue(tlvpValue);
if (!multiValue.isSetObservationID()) {
if (value instanceof AbstractObservationValue && ((AbstractObservationValue) value).isSetObservationID()) {
multiValue.setObservationID(((AbstractObservationValue) value).getObservationID());
} else if (isSetObservationID()) {
multiValue.setObservationID(getObservationID());
}
}
super.setValue(multiValue);
}
}
Aggregations