Search in sources :

Example 6 with UoM

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

the class FieldDecoderTest method timeRangeWithValue.

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

Example 7 with UoM

use of org.n52.shetland.ogc.UoM 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 8 with UoM

use of org.n52.shetland.ogc.UoM 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 9 with UoM

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

the class WmlTVPEncoderv20 method createMeasurementTimeseries.

/**
 * Create a XML MeasurementTimeseries object from SOS observation for
 * om:result
 *
 * @param sosObservation
 *            SOS observation
 *
 * @return XML MeasurementTimeseries object
 *
 * @throws CodedException
 *             if the encoding fails
 */
private XmlObject createMeasurementTimeseries(OmObservation sosObservation) throws OwsExceptionReport {
    MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
    MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
    measurementTimeseries.setId(TIMESERIES_ID_PREFIX + sosObservation.getObservationID());
    // Default value
    TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
    if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getValue().getValue().getClass().isAssignableFrom(TVPValue.class) && sosObservation.getObservationConstellation().isSetMetadata() && sosObservation.getObservationConstellation().getMetadata().isSetTimeseriesMetadata()) {
        timeseriesMetadata = sosObservation.getObservationConstellation().getMetadata().getTimeseriesmetadata();
    }
    addTimeseriesMetadata(measurementTimeseries, sosObservation.getPhenomenonTime().getGmlId(), timeseriesMetadata);
    TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
    TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
    // Default value
    InterpolationType interpolationType = InterpolationType.Continuous;
    if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getObservationConstellation().isSetDefaultPointMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        interpolationType = sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
    }
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
    String unit = addValues(measurementTimeseries, sosObservation.getValue());
    // set uom
    if (unit != null && !unit.isEmpty()) {
        defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
    } else {
        OmObservableProperty observableProperty = (OmObservableProperty) sosObservation.getObservationConstellation().getObservableProperty();
        if (observableProperty.isSetUnit()) {
            defaultTVPMeasurementMetadata.addNewUom().setCode(observableProperty.getUnit());
        }
    }
    xbMetaComponent.set(xbDefMeasureMetaComponent);
    return measurementTimeseriesDoc;
}
Also used : TimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) MeasurementTimeseriesType(net.opengis.waterml.x20.MeasurementTimeseriesType) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) TVPMeasurementMetadataType(net.opengis.waterml.x20.TVPMeasurementMetadataType) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType) MeasurementTimeseriesDocument(net.opengis.waterml.x20.MeasurementTimeseriesDocument) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 10 with UoM

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

the class SweCommonEncoderv101Test method should_encode_ReferencedEnvelope.

@Test
public void should_encode_ReferencedEnvelope() throws EncodingException {
    final int srid = 4326;
    final double y1 = 7.0;
    final double x1 = 51.0;
    final double y2 = 8.0;
    final double x2 = 52.0;
    final String uom = "test-uom";
    final String definition = "test-definition";
    final SweEnvelope sweEnvelope = new SweEnvelope(new ReferencedEnvelope(new Envelope(x1, x2, y1, y2), srid), uom, true);
    final String xAxisId = "x";
    final String yAxisId = "y";
    final String northing = "northing";
    final String easting = "easting";
    sweEnvelope.setDefinition(definition);
    final XmlObject encode = sweCommonEncoderv101.encode(sweEnvelope);
    assertThat(encode, instanceOf(EnvelopeType.class));
    final EnvelopeType xbEnvelope = (EnvelopeType) encode;
    assertThat(xbEnvelope.isSetDefinition(), is(true));
    assertThat(xbEnvelope.getDefinition(), is(definition));
    final Coordinate lcX = xbEnvelope.getLowerCorner().getVector().getCoordinateArray(0);
    assertThat(lcX.getName(), is(easting));
    assertThat(lcX.getQuantity().getAxisID(), is(xAxisId));
    assertThat(lcX.getQuantity().getUom().getCode(), is(uom));
    assertThat(lcX.getQuantity().getValue(), is(y1));
    final Coordinate lcY = xbEnvelope.getLowerCorner().getVector().getCoordinateArray(1);
    assertThat(lcY.getName(), is(northing));
    assertThat(lcY.getQuantity().getAxisID(), is(yAxisId));
    assertThat(lcY.getQuantity().getUom().getCode(), is(uom));
    assertThat(lcY.getQuantity().getValue(), is(x1));
    final Coordinate ucX = xbEnvelope.getUpperCorner().getVector().getCoordinateArray(0);
    assertThat(ucX.getName(), is(easting));
    assertThat(ucX.getQuantity().getAxisID(), is(xAxisId));
    assertThat(ucX.getQuantity().getUom().getCode(), is(uom));
    assertThat(ucX.getQuantity().getValue(), is(y2));
    final Coordinate ucY = xbEnvelope.getUpperCorner().getVector().getCoordinateArray(1);
    assertThat(ucY.getName(), is(northing));
    assertThat(ucY.getQuantity().getAxisID(), is(yAxisId));
    assertThat(ucY.getQuantity().getUom().getCode(), is(uom));
    assertThat(ucY.getQuantity().getValue(), is(x2));
    assertThat(xbEnvelope.isSetReferenceFrame(), is(true));
    assertThat(xbEnvelope.getReferenceFrame(), is("" + srid));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) EnvelopeType(net.opengis.swe.x101.EnvelopeType) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Coordinate(net.opengis.swe.x101.VectorType.Coordinate) XmlObject(org.apache.xmlbeans.XmlObject) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 SweField (org.n52.shetland.ogc.swe.SweField)9 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)8 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)4 ParameterOutput (org.n52.io.response.ParameterOutput)3 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3 BigDecimal (java.math.BigDecimal)2 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)2 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)2 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)2 Envelope (org.locationtech.jts.geom.Envelope)2 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)2 MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata)2 TimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata)2 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)2 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)2