Search in sources :

Example 16 with UoM

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

the class FieldDecoderTest method testQuantityWithValue.

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

Example 17 with UoM

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

the class InsertObservationRequestEncoderTest method createInsertObservationRequest.

private InsertObservationRequest createInsertObservationRequest() throws InvalidSridException, ParseException {
    SamplingFeature samplingFeature = new SamplingFeature(new CodeWithAuthority("test-feature-uri"));
    samplingFeature.setName(new CodeType("test-feature-name"));
    samplingFeature.setSampledFeatures(Arrays.asList(new SamplingFeature(new CodeWithAuthority("test-parent-feature-uri"))));
    samplingFeature.setGeometry(JTSHelper.createGeometryFromWKT("POINT(52.0 42.0)", 4326));
    PhysicalSystem procedure = new PhysicalSystem();
    procedure.setIdentifier("test-procedure");
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setGmlId("o1");
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationConstellation.setObservableProperty(new OmObservableProperty("test-property"));
    observationConstellation.setFeatureOfInterest(samplingFeature);
    observationConstellation.setProcedure(procedure);
    TimeInstant time = new TimeInstant(new Date(0));
    QuantityValue quantity = new QuantityValue(23.0, "test-uom");
    ObservationValue<?> value = new SingleObservationValue<>(time, quantity);
    OmObservation omObservation = new OmObservation();
    omObservation.setObservationConstellation(observationConstellation);
    omObservation.setResultTime(time);
    omObservation.setValue(value);
    InsertObservationRequest request = new InsertObservationRequest("SOS", "2.0.0");
    request.setOfferings(Arrays.asList(OFFERING_ID));
    request.addObservation(omObservation);
    return request;
}
Also used : PhysicalSystem(org.n52.shetland.ogc.sensorML.v20.PhysicalSystem) OmObservation(org.n52.shetland.ogc.om.OmObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Date(java.util.Date) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) CodeType(org.n52.shetland.ogc.gml.CodeType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 18 with UoM

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

the class SweCommonDecoderV101Test method should_decode_QuantityRange.

@Test
public void should_decode_QuantityRange() throws DecodingException {
    final QuantityRangeDocument xbQuantityRange = QuantityRangeDocument.Factory.newInstance();
    final ArrayList<BigDecimal> values = Lists.newArrayList(BigDecimal.valueOf(1.0), BigDecimal.valueOf(2.0));
    final QuantityRange xbQuantityRangeType = xbQuantityRange.addNewQuantityRange();
    xbQuantityRangeType.setValue(values);
    final String definition = "definition";
    xbQuantityRangeType.setDefinition(definition);
    final String axisId = "axis-id";
    xbQuantityRangeType.setAxisID(axisId);
    final String description = "description";
    xbQuantityRangeType.addNewDescription().setStringValue(description);
    final UomPropertyType xbUom = xbQuantityRangeType.addNewUom();
    final String uomCode = "uom-code";
    xbUom.setCode(uomCode);
    final Object decodedObject = new SweCommonDecoderV101().decode(xbQuantityRange);
    assertThat(decodedObject, is(instanceOf(SweQuantityRange.class)));
    final SweQuantityRange sweQuantityRange = (SweQuantityRange) decodedObject;
    assertThat(sweQuantityRange.isSetDefinition(), is(true));
    assertThat(sweQuantityRange.getDefinition(), is(definition));
    assertThat(sweQuantityRange.isSetUom(), is(true));
    assertThat(sweQuantityRange.getUom(), is(uomCode));
    assertThat(sweQuantityRange.isSetAxisID(), is(true));
    assertThat(sweQuantityRange.getAxisID(), is(axisId));
    assertThat(sweQuantityRange.isSetDescription(), is(true));
    assertThat(sweQuantityRange.getDescription(), is(description));
    assertThat(sweQuantityRange.isSetValue(), is(true));
    assertThat(sweQuantityRange.getValue().getRangeStart(), is(values.get(0)));
    assertThat(sweQuantityRange.getValue().getRangeEnd(), is(values.get(1)));
}
Also used : UomPropertyType(net.opengis.swe.x101.UomPropertyType) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) QuantityRangeDocument(net.opengis.swe.x101.QuantityRangeDocument) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) QuantityRange(net.opengis.swe.x101.QuantityRangeDocument.QuantityRange) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 19 with UoM

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

the class WmlTVPEncoderv20 method createMeasurementTimeseries.

private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws CodedException {
    MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
    MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
    measurementTimeseries.setId(TIMESERIES_ID_PREFIX + observationValue.getObservationID());
    // Default value
    TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
    if (observationValue.isSetValue() && observationValue.isSetMetadata() && observationValue.getMetadata().isSetTimeseriesMetadata()) {
        timeseriesMetadata = observationValue.getMetadata().getTimeseriesmetadata();
    }
    addTimeseriesMetadata(measurementTimeseries, observationValue.getPhenomenonTime().getGmlId(), timeseriesMetadata);
    TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
    TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
    // Default value
    InterpolationType interpolationType = InterpolationType.Continuous;
    if (observationValue.isSetValue() && observationValue.isSetDefaultPointMetadata() && observationValue.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        interpolationType = observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
    }
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
    String unit = addValues(measurementTimeseries, observationValue);
    // 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) 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)

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