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));
}
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;
}
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)));
}
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;
}
Aggregations