Search in sources :

Example 81 with Value

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;
    }
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 82 with Value

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));
    }
}
Also used : MultiPointCoverage(org.n52.shetland.ogc.om.values.MultiPointCoverage) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Example 83 with Value

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

Example 84 with Value

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));
}
Also used : TimePosition(org.n52.shetland.ogc.gml.time.TimePosition) Test(org.junit.Test)

Example 85 with Value

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()));
}
Also used : TimePosition(org.n52.shetland.ogc.gml.time.TimePosition) Test(org.junit.Test)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5