Search in sources :

Example 91 with Value

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

the class TextObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_TEXT_OBSERVATION)));
    final ObservationValue<?> value = observation.getValue();
    assertThat(value, is(instanceOf(SingleObservationValue.class)));
    assertThat(value.getPhenomenonTime(), is(instanceOf(TimeInstant.class)));
    TimeInstant pt = (TimeInstant) value.getPhenomenonTime();
    assertThat(pt.getValue(), is(equalTo(phenomenonTime)));
    assertThat(value.getValue(), is(instanceOf(TextValue.class)));
    TextValue v = (TextValue) value.getValue();
    assertThat(v.getValue(), is(equalTo("Some Value")));
    assertThat(v.getUnit(), is(nullValue()));
}
Also used : TextValue(org.n52.shetland.ogc.om.values.TextValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 92 with Value

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

the class CategoryObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_CATEGORY_OBSERVATION)));
    final ObservationValue<?> value = observation.getValue();
    assertThat(value, is(instanceOf(SingleObservationValue.class)));
    assertThat(value.getPhenomenonTime(), is(instanceOf(TimeInstant.class)));
    TimeInstant pt = (TimeInstant) value.getPhenomenonTime();
    assertThat(pt.getValue(), is(equalTo(phenomenonTime)));
    assertThat(value.getValue(), is(instanceOf(CategoryValue.class)));
    CategoryValue v = (CategoryValue) value.getValue();
    assertThat(v.getValue(), is(equalTo("Some Value")));
    assertThat(v.getUnit(), is(equalTo("http://52north.org/")));
}
Also used : CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 93 with Value

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

the class GeometryObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_GEOMETRY_OBSERVATION)));
    final ObservationValue<?> value = observation.getValue();
    assertThat(value, is(instanceOf(SingleObservationValue.class)));
    assertThat(value.getPhenomenonTime(), is(instanceOf(TimeInstant.class)));
    TimeInstant pt = (TimeInstant) value.getPhenomenonTime();
    assertThat(pt.getValue(), is(equalTo(phenomenonTime)));
    assertThat(value.getValue(), is(instanceOf(GeometryValue.class)));
    GeometryValue v = (GeometryValue) value.getValue();
    assertThat(v.getUnit(), is(nullValue()));
    Geometry g = v.getValue();
    assertThat(g, is(instanceOf(LineString.class)));
    assertThat(g.getSRID(), is(2000));
    assertThat(g.getNumPoints(), is(2));
    assertThat(g.getCoordinates()[0], is(equalTo(new Coordinate(52, 7))));
    assertThat(g.getCoordinates()[1], is(equalTo(new Coordinate(51, 7))));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 94 with Value

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

the class SweCommonDecoderV101 method parseCountRange.

private SweCountRange parseCountRange(CountRange xbCountRange) throws DecodingException {
    SweCountRange sosCountRange = new SweCountRange();
    // }
    if (xbCountRange.getQualityArray() != null) {
        sosCountRange.setQuality(parseQuality(xbCountRange.getQualityArray()));
    }
    // }
    if (xbCountRange.isSetDefinition()) {
        sosCountRange.setDefinition(xbCountRange.getDefinition());
    }
    if (xbCountRange.isSetDescription()) {
        sosCountRange.setDescription(xbCountRange.getDescription().getStringValue());
    }
    if (xbCountRange.isSetValue()) {
        List<?> value = xbCountRange.getValue();
        Integer rangeStart = Integer.parseInt(value.get(0).toString());
        Integer rangeEnd = Integer.parseInt(value.get(1).toString());
        sosCountRange.setValue(new RangeValue<>(rangeStart, rangeEnd));
    }
    return sosCountRange;
}
Also used : SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange)

Example 95 with Value

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

the class SweCommonDecoderV101 method parseEnvelope.

private SweAbstractDataComponent parseEnvelope(EnvelopeType envelopeType) throws DecodingException {
    String referenceFrame = null;
    SweVector lowerCorner = null;
    SweVector upperCorner = null;
    SweTimeRange time = null;
    if (envelopeType.isSetReferenceFrame()) {
        referenceFrame = envelopeType.getReferenceFrame();
    }
    if (envelopeType.getLowerCorner() != null) {
        lowerCorner = parseVectorProperty(envelopeType.getLowerCorner());
    }
    if (envelopeType.getUpperCorner() != null) {
        upperCorner = parseVectorProperty(envelopeType.getUpperCorner());
    }
    if (envelopeType.isSetTime()) {
        time = parseTimeRange(envelopeType.getTime().getTimeRange());
    }
    // FIXME get the northing first value for the reference frame
    boolean northingFirst = false;
    return new SweEnvelope(referenceFrame, upperCorner, lowerCorner, time, northingFirst);
}
Also used : SweVector(org.n52.shetland.ogc.swe.SweVector) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange)

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