Search in sources :

Example 16 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldDecoderTest method testBoolean.

@Test
public void testBoolean() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.BOOLEAN_TYPE);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweBoolean.class)));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Example 17 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldDecoderTest method testQuantityRangeWithValue.

@Test
public void testQuantityRangeWithValue() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_RANGE_TYPE).put(JSONConstants.UOM, UOM);
    json.putArray(JSONConstants.VALUE).add(QUANTITY_VALUE_START).add(QUANTITY_VALUE_END);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweQuantityRange.class)));
    SweQuantityRange swe = (SweQuantityRange) field.getElement();
    errors.checkThat(swe.getUom(), is(UOM));
    errors.checkThat(swe.getValue(), is(notNullValue()));
    errors.checkThat(swe.getValue().getRangeStart().doubleValue(), is(QUANTITY_VALUE_START));
    errors.checkThat(swe.getValue().getRangeEnd().doubleValue(), is(QUANTITY_VALUE_END));
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Example 18 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldDecoderTest method checkCommon.

protected SweField checkCommon(ObjectNode json, boolean withValue) throws DecodingException {
    SweField field = validateWithValueAndDecode(json, withValue);
    assertThat(field, is(notNullValue()));
    errors.checkThat(field.getName().getValue(), is(NAME));
    assertThat(field.getElement(), is(notNullValue()));
    errors.checkThat(field.getElement().getDefinition(), is(DEFINITION));
    errors.checkThat(field.getElement().getDescription(), is(DESCRIPTION));
    errors.checkThat(field.getElement().getIdentifier(), is(IDENTIFIER));
    errors.checkThat(field.getElement().getLabel(), is(LABEL));
    return field;
}
Also used : SweField(org.n52.shetland.ogc.swe.SweField)

Example 19 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class InsertResultTemplateRequestDecoderTest method resultStructure.

@Test
public void resultStructure() throws IOException, DecodingException {
    InsertResultTemplateRequest req = load();
    assertThat(req.getResultStructure(), is(notNullValue()));
    assertThat(req.getResultStructure().isDecoded(), is(true));
    assertThat(req.getResultStructure().isEncoded(), is(false));
    assertThat(req.getResultStructure().get().get(), is(instanceOf(SweDataRecord.class)));
    SweDataRecord structure = (SweDataRecord) req.getResultStructure().get().get();
    assertThat(structure.getFields(), is(notNullValue()));
    assertThat(structure.getFields(), hasSize(3));
    SweField field1 = structure.getFields().get(0);
    assertThat(field1, is(notNullValue()));
    errors.checkThat(field1.getName().getValue(), is("phenomenonTime"));
    assertThat(field1.getElement(), is(instanceOf(SweTimeRange.class)));
    SweTimeRange phenomenonTime = (SweTimeRange) field1.getElement();
    errors.checkThat(phenomenonTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/PhenomenonTime"));
    errors.checkThat(phenomenonTime.getUom(), is("http://www.opengis.net/def/uom/ISO-8601/0/Gregorian"));
    SweField field2 = structure.getFields().get(1);
    assertThat(field2, is(notNullValue()));
    errors.checkThat(field2.getName().getValue(), is("resultTime"));
    assertThat(field2.getElement(), is(instanceOf(SweTime.class)));
    SweTime resultTime = (SweTime) field2.getElement();
    errors.checkThat(resultTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/ResultTime"));
    errors.checkThat(resultTime.getUom(), is("testunit1"));
    SweField field3 = structure.getFields().get(2);
    assertThat(field3, is(notNullValue()));
    errors.checkThat(field3.getName().getValue(), is("observable_property_6"));
    assertThat(field3.getElement(), is(instanceOf(SweQuantity.class)));
    SweQuantity quantity = (SweQuantity) field3.getElement();
    errors.checkThat(quantity.getDefinition(), is("http://www.52north.org/test/observableProperty/6"));
    errors.checkThat(quantity.getUom(), is("test_unit_6"));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 20 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldEncoder method encodeSweCountRangeField.

private ObjectNode encodeSweCountRangeField(SweField field) {
    ObjectNode jfield = createField(field);
    jfield.put(JSONConstants.TYPE, JSONConstants.COUNT_RANGE_TYPE);
    SweCountRange sweCountRange = (SweCountRange) field.getElement();
    if (sweCountRange.isSetValue()) {
        ArrayNode av = jfield.putArray(JSONConstants.VALUE);
        av.add(sweCountRange.getValue().getRangeStart());
        av.add(sweCountRange.getValue().getRangeEnd());
    }
    return jfield;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

SweField (org.n52.shetland.ogc.swe.SweField)59 Test (org.junit.Test)42 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)34 XmlObject (org.apache.xmlbeans.XmlObject)20 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)19 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)19 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)12 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)12 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)11 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)11 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)11 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)10 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)10 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)9 DataRecordType (net.opengis.swe.x101.DataRecordType)9 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)9 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)9 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)8 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)7 DateTime (org.joda.time.DateTime)4