Search in sources :

Example 56 with Value

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

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCategory.

@Test
public void should_encode_Datarecord_with_fieldCategory() throws EncodingException {
    final String field1Name = "test-name";
    final String field1Value = "test-value";
    final String codeSpace = "test-codespace";
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCategory().setCodeSpace(codeSpace).setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetCategory(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getCategory().getValue(), is(field1Value));
    assertThat(field1.getCategory().getCodeSpace().getHref(), is(codeSpace));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 57 with Value

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

the class OmDecoderV20Test method testComplexObservation.

@Test
public void testComplexObservation() throws XmlException, DecodingException {
    XmlObject xml = XmlObject.Factory.parse(getComplexObservationXml());
    // FIXME
    // Object decoded = CodingHelper.decodeXmlObject(xml);
    Object decoded = omDecoderv20.decode(xml);
    assertThat(decoded, is(instanceOf(OmObservation.class)));
    OmObservation observation = (OmObservation) decoded;
    assertThat(observation.getValue(), is(instanceOf(SingleObservationValue.class)));
    assertThat(observation.getValue().getValue(), is(instanceOf(ComplexValue.class)));
    ComplexValue value = (ComplexValue) observation.getValue().getValue();
    assertThat(value.getValue(), is(notNullValue()));
    SweAbstractDataRecord dataRecord = value.getValue();
    assertThat(dataRecord.getFields(), hasSize(5));
    SweField field1 = dataRecord.getFields().get(0);
    SweField field2 = dataRecord.getFields().get(1);
    SweField field3 = dataRecord.getFields().get(2);
    SweField field4 = dataRecord.getFields().get(3);
    SweField field5 = dataRecord.getFields().get(4);
    errors.checkThat(field1.getElement().getDefinition(), is("http://example.tld/phenomenon/child/1"));
    errors.checkThat(field2.getElement().getDefinition(), is("http://example.tld/phenomenon/child/2"));
    errors.checkThat(field3.getElement().getDefinition(), is("http://example.tld/phenomenon/child/3"));
    errors.checkThat(field4.getElement().getDefinition(), is("http://example.tld/phenomenon/child/4"));
    errors.checkThat(field5.getElement().getDefinition(), is("http://example.tld/phenomenon/child/5"));
    errors.checkThat(field1.getElement().getDataComponentType(), is(SweDataComponentType.Quantity));
    errors.checkThat(field2.getElement().getDataComponentType(), is(SweDataComponentType.Boolean));
    errors.checkThat(field3.getElement().getDataComponentType(), is(SweDataComponentType.Count));
    errors.checkThat(field4.getElement().getDataComponentType(), is(SweDataComponentType.Text));
    errors.checkThat(field5.getElement().getDataComponentType(), is(SweDataComponentType.Category));
}
Also used : ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweAbstractDataRecord(org.n52.shetland.ogc.swe.SweAbstractDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) OmObservation(org.n52.shetland.ogc.om.OmObservation) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Example 58 with Value

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

the class GWGeologyLogCoveragePropertyEncoderTest method createProfileLevel.

private List<Value<?>> createProfileLevel() {
    List<Value<?>> list = Lists.newArrayList();
    CategoryValue category = new CategoryValue("weathered grey brown basalt", "unknown");
    category.setDefinition("http://www.opengis.net/def/gwml/2.0/observedProperty/earthMaterial");
    category.addName(new CodeType("lithology"));
    list.add(category);
    TextValue text = new TextValue("weathered grey brown basalt");
    text.setDefinition("http://www.opengis.net/def/gwml/2.0/observedProperty/earthMaterial");
    text.addName(new CodeType("text"));
    list.add(text);
    return list;
}
Also used : TextValue(org.n52.shetland.ogc.om.values.TextValue) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) TextValue(org.n52.shetland.ogc.om.values.TextValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) Value(org.n52.shetland.ogc.om.values.Value) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) CodeType(org.n52.shetland.ogc.gml.CodeType)

Example 59 with Value

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

the class GWGeologyLogCoveragePropertyEncoderTest method createQuantity.

private QuantityValue createQuantity(String definition, double value, String unit) {
    QuantityValue quantity = new QuantityValue(value, unit);
    quantity.setValue(value).setUom(unit).setDefinition(definition);
    return quantity;
}
Also used : QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue)

Example 60 with Value

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

the class WmlTVPEncoderv20Test method initObjects.

@Before
public void initObjects() {
    encoder = new WmlTVPEncoderv20();
    MultiValue<List<TimeValuePair>> value = new TVPValue();
    String unit = "test-unit";
    value.setUnit(unit);
    TimeValuePair tvp1 = new TimeValuePair(new TimeInstant(new Date(UTC_TIMESTAMP)), new QuantityValue(52.1234567890));
    List<TimeValuePair> valueList = CollectionHelper.list(tvp1);
    value.setValue(valueList);
    mv = new MultiObservationValues<>();
    mv.setValue(value);
}
Also used : TVPValue(org.n52.shetland.ogc.om.values.TVPValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) List(java.util.List) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Date(java.util.Date) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair) Before(org.junit.Before)

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