use of org.n52.shetland.ogc.om.series.DefaultPointMetadata in project arctic-sea by 52North.
the class TsmlTVPEncoderv10Test method shouldEncodeInterpolationType.
@Test
public void shouldEncodeInterpolationType() throws EncodingException, XmlException {
final InterpolationType type = TimeseriesMLConstants.InterpolationType.MinPrec;
mv.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
XmlObject encodedElement = encoder.encode(mv);
TimeseriesTVPType.DefaultPointMetadata defaultPointMetadata = ((TimeseriesTVPDocument) encodedElement).getTimeseriesTVP().getDefaultPointMetadata();
PointMetadataDocument tvpMeasurementMetadataDocument = PointMetadataDocument.Factory.parse(defaultPointMetadata.xmlText());
ReferenceType interpolationType = tvpMeasurementMetadataDocument.getPointMetadata().getInterpolationType();
MatcherAssert.assertThat(interpolationType.getHref(), Is.is(TimeseriesMLConstants.InterpolationType.MinPrec.getIdentifier()));
MatcherAssert.assertThat(interpolationType.getTitle(), Is.is(TimeseriesMLConstants.InterpolationType.MinPrec.getTitle()));
}
use of org.n52.shetland.ogc.om.series.DefaultPointMetadata in project arctic-sea by 52North.
the class TsmlTVPEncoderv10Test method createObservation.
private OmObservation createObservation() {
final InterpolationType type = TimeseriesMLConstants.InterpolationType.InstantTotal;
DateTime now = new DateTime(DateTimeZone.UTC);
TimeInstant resultTime = new TimeInstant(now);
TimePeriod validTime = new TimePeriod(now.minusMinutes(5), now.plusMinutes(5));
OmObservation observation = new OmObservation();
OmObservationConstellation observationConstellation = new OmObservationConstellation();
observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
observationConstellation.setObservableProperty(new OmObservableProperty("omobservableProperty"));
observationConstellation.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
observationConstellation.setObservationType(OmConstants.OBS_TYPE_OBSERVATION);
observationConstellation.addOffering(OFFERING);
AbstractFeature procedure = new SosProcedureDescriptionUnknownType(PROCEDURE);
observationConstellation.setProcedure(procedure);
observation.setObservationConstellation(observationConstellation);
observation.setParameter(null);
observation.setResultTime(resultTime);
observation.setTokenSeparator(TOKEN_SEPERATOR);
observation.setTupleSeparator(TUPLE_SEPERATOR);
observation.setValidTime(validTime);
observation.setValue(mv);
return observation;
}
use of org.n52.shetland.ogc.om.series.DefaultPointMetadata in project arctic-sea by 52North.
the class WmlTVPEncoderv20Test method shouldEncodeInterpolationType.
@Test
public void shouldEncodeInterpolationType() throws EncodingException, XmlException {
final InterpolationType type = WaterMLConstants.InterpolationType.MinPrec;
mv.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
XmlObject encodedElement = encoder.encode(mv);
TVPDefaultMetadataPropertyType defaultPointMetadata = ((MeasurementTimeseriesDocument) encodedElement).getTimeseries().getDefaultPointMetadataArray(0);
DefaultTVPMeasurementMetadataDocument tvpMeasurementMetadataDocument = DefaultTVPMeasurementMetadataDocument.Factory.parse(defaultPointMetadata.xmlText());
ReferenceType interpolationType = tvpMeasurementMetadataDocument.getDefaultTVPMeasurementMetadata().getInterpolationType();
assertThat(interpolationType.getHref(), Is.is(WaterMLConstants.InterpolationType.MinPrec.getIdentifier()));
assertThat(interpolationType.getTitle(), Is.is(WaterMLConstants.InterpolationType.MinPrec.getTitle()));
}
use of org.n52.shetland.ogc.om.series.DefaultPointMetadata in project arctic-sea by 52North.
the class UVFEncoderTest method initObjects.
@BeforeEach
public void initObjects() throws OwsExceptionReport, ParseException {
encoder = new UVFEncoder();
final OmObservation omObservation = new OmObservation();
OmObservationConstellation observationConstellation = new OmObservationConstellation();
omObservation.setObservationID("1");
// Observed Property
String valueType = "test-obs-prop-value-type";
String description = "test-obs-prop-description";
AbstractPhenomenon observableProperty = new OmObservableProperty(obsPropIdentifier, description, unit, valueType);
observationConstellation.setObservableProperty(observableProperty);
// Feature Of Interest
CodeWithAuthority featureIdentifier = new CodeWithAuthority(foiIdentifier);
AbstractFeature featureOfInterest = new SamplingFeature(featureIdentifier);
featureOfInterest.addName(new CodeType(foiName));
int srid = 4326;
String geomWKT = "POINT(51.9350382 7.6521225)";
final Geometry point = JTSHelper.createGeometryFromWKT(geomWKT, srid);
((SamplingFeature) featureOfInterest).setGeometry(point);
observationConstellation.setFeatureOfInterest(featureOfInterest);
// value
final String uomId = "test-uom";
final double testValue = 52.0;
Value<?> measuredValue = new QuantityValue(testValue, uomId);
// timestamps
Time phenomenonTime = new TimeInstant(new Date(UTC_TIMESTAMP_1));
// observation value
ObservationValue<?> value = new SingleObservationValue<>(phenomenonTime, measuredValue);
value.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(InterpolationType.Continuous)));
omObservation.setValue(value);
// observation type
observationConstellation.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
// Final package
omObservation.setObservationConstellation(observationConstellation);
responseToEncode = new GetObservationResponse();
responseToEncode.setObservationCollection(ObservationStream.of(omObservation));
}
use of org.n52.shetland.ogc.om.series.DefaultPointMetadata in project SOS by 52North.
the class WaterMLMetadataAdder method add.
public WaterMLMetadataAdder add() throws CodedException {
if (series.hasParameters()) {
OmObservationConstellation observationConstellation = omObservation.getObservationConstellation();
/*
* Add interpolation type
*/
if (!observationConstellation.isSetDefaultPointMetadata()) {
observationConstellation.setDefaultPointMetadata(new DefaultPointMetadata());
}
if (!observationConstellation.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata()) {
observationConstellation.getDefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata());
}
/*
* Get interpolation type from database
*/
Optional<Object> interpolationTypeTitle = getMetadataElement(series, WaterMLConstants.NS_WML_20, WaterMLConstants.INTERPOLATION_TYPE);
/*
* Default Value
*/
InterpolationType interpolationType = WaterMLConstants.InterpolationType.Continuous;
if (interpolationTypeTitle.isPresent()) {
try {
interpolationType = InterpolationType.from(interpolationTypeTitle.get().toString());
} catch (IllegalArgumentException iae) {
throw createMetadataInvalidException(WaterMLConstants.INTERPOLATION_TYPE, interpolationType.getTitle(), iae);
}
}
observationConstellation.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().setInterpolationtype(interpolationType);
/*
* Add cumulative
*/
if (!observationConstellation.isSetMetadata()) {
observationConstellation.setMetadata(new Metadata());
}
if (!observationConstellation.getMetadata().isSetTimeseriesMetadata()) {
observationConstellation.getMetadata().setTimeseriesmetadata(new MeasurementTimeseriesMetadata());
}
Optional<Object> cumulativeMetadata = getMetadataElement(series, WaterMLConstants.NS_WML_20, WaterMLConstants.SERIES_METADATA_CUMULATIVE);
/*
* Default Value
*/
boolean cumulative = false;
if (cumulativeMetadata.isPresent()) {
String cumulativeMetadataValue = cumulativeMetadata.get().toString();
if (!cumulativeMetadataValue.isEmpty() && (cumulativeMetadataValue.equalsIgnoreCase("true") || cumulativeMetadataValue.equalsIgnoreCase("false") || cumulativeMetadataValue.equalsIgnoreCase("1") || cumulativeMetadataValue.equalsIgnoreCase("0"))) {
if (cumulativeMetadataValue.equals("1")) {
cumulative = true;
} else {
cumulative = Boolean.parseBoolean(cumulativeMetadataValue);
}
} else {
throw createMetadataInvalidException(WaterMLConstants.SERIES_METADATA_CUMULATIVE, cumulativeMetadataValue, null);
}
}
((MeasurementTimeseriesMetadata) observationConstellation.getMetadata().getTimeseriesmetadata()).setCumulative(cumulative);
}
return this;
}
Aggregations