Search in sources :

Example 31 with Value

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

the class JSONDecoder method parseCodeWithAuthority.

protected CodeWithAuthority parseCodeWithAuthority(JsonNode node) {
    if (node.isObject()) {
        String value = node.path(JSONConstants.VALUE).textValue();
        String codespace = node.path(JSONConstants.CODESPACE).textValue();
        if (codespace == null || codespace.isEmpty()) {
            codespace = OGCConstants.UNKNOWN;
        }
        return new CodeWithAuthority(value, codespace);
    } else if (node.isTextual()) {
        return new CodeWithAuthority(node.textValue(), OGCConstants.UNKNOWN);
    } else {
        return null;
    }
}
Also used : CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 32 with Value

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

the class CountObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_COUNT_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(CountValue.class)));
    CountValue v = (CountValue) value.getValue();
    assertThat(v.getValue(), is(1));
    assertThat(v.getUnit(), is(nullValue()));
}
Also used : CountValue(org.n52.shetland.ogc.om.values.CountValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 33 with Value

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

the class AbstractCapabilitiesBaseTypeDecoder method parseValuesReference.

private OwsValuesReference parseValuesReference(ValuesReference valuesReference) {
    if (valuesReference == null) {
        return null;
    }
    URI reference = Optional.ofNullable(valuesReference.getReference()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    String value = valuesReference.getStringValue();
    return new OwsValuesReference(reference, value);
}
Also used : OwsValuesReference(org.n52.shetland.ogc.ows.OwsValuesReference) LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) URI(java.net.URI) Strings(com.google.common.base.Strings)

Example 34 with Value

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

the class AbstractCapabilitiesBaseTypeDecoder method parse.

private <T extends OwsDomainMetadata> T parse(BiFunction<URI, String, T> fun, DomainMetadataType metadata) {
    if (metadata == null) {
        return null;
    }
    URI reference = Optional.ofNullable(metadata.getReference()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    String value = metadata.getStringValue();
    return fun.apply(reference, value);
}
Also used : LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) URI(java.net.URI) Strings(com.google.common.base.Strings)

Example 35 with Value

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

the class TruthObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_TRUTH_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(BooleanValue.class)));
    BooleanValue v = (BooleanValue) value.getValue();
    assertThat(v.getValue(), is(true));
    assertThat(v.getUnit(), is(nullValue()));
}
Also used : BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) 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