use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class SpatialFilterDecoder method decodeJSON.
@Override
public SpatialFilter decodeJSON(JsonNode node, boolean validate) throws DecodingException {
if (node == null || node.isNull() || node.isMissingNode()) {
return null;
}
if (validate) {
JSONValidator.getInstance().validateAndThrow(node, SchemaConstants.Common.SPATIAL_FILTER);
}
if (node.isObject()) {
final String oName = node.fields().next().getKey();
final SOp o = SOp.valueOf(oName);
JsonNode value = node.path(oName).path(JSONConstants.VALUE);
JsonNode ref = node.path(oName).path(JSONConstants.REF);
return new SpatialFilter(o.getOp(), decodeGeometry(value), ref.textValue());
} else {
return null;
}
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class MultiPointObservation method setValue.
@Override
public void setValue(ObservationValue<?> value) {
if (value.getValue() instanceof MultiPointCoverage) {
super.setValue(value);
} else {
MultiPointCoverage multiPointCoverage = new MultiPointCoverage(getObservationID());
multiPointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
multiPointCoverage.addValue(new PointValuePair(getPoint(), value.getValue()));
super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), multiPointCoverage));
}
}
use of org.n52.shetland.ogc.om.values.Value 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));
}
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class TimeTest method datetime.
@Test
public void datetime() {
TimePosition timePosition = new TimePosition(DateTime.now());
assertThat("time position is set", timePosition.isSetTime(), is(true));
assertThat("indeterminate value is not", timePosition.isSetIndeterminateValue(), is(false));
assertThat("time format is set", timePosition.isSetTimeFormat(), is(true));
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class TimeTest method format.
@Test
public void format() {
TimePosition timePosition = new TimePosition(DateTime.now(), Time.TimeFormat.ISO8601);
assertThat("time position is set", timePosition.isSetTime(), is(true));
assertThat("indeterminate value is not set", timePosition.isSetIndeterminateValue(), is(false));
assertThat("format is set", timePosition.isSetTimeFormat(), is(true));
assertThat("format is correct", timePosition.getTimeFormat().toString(), is(Time.TimeFormat.ISO8601.toString()));
}
Aggregations