use of org.n52.shetland.ogc.om.series.tsml.DefaultTVPMeasurementMetadata 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.tsml.DefaultTVPMeasurementMetadata 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.tsml.DefaultTVPMeasurementMetadata 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.tsml.DefaultTVPMeasurementMetadata 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.tsml.DefaultTVPMeasurementMetadata in project arctic-sea by 52North.
the class TrajectoryObservationTypeEncoder method createMeasurementTimeseries.
/**
* Encode {@link AbstractObservationValue} to
* {@link MeasurementTimeseriesDocument}
*
* @param observationValue
* The {@link AbstractObservationValue} to encode
* @return The encoded {@link AbstractObservationValue}
* @throws EncodingException
* If an error occurs
*/
private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws EncodingException {
MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
if (!observationValue.isSetObservationID()) {
observationValue.setObservationID(IdGenerator.generate(observationValue.toString()));
}
measurementTimeseries.setId(TIMESERIES_PREFIX + observationValue.getObservationID());
measurementTimeseries.addNewMetadata().addNewTimeseriesMetadata().addNewTemporalExtent().setHref("#" + observationValue.getPhenomenonTime().getGmlId());
TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
defaultTVPMeasurementMetadata.addNewInterpolationType().setHref("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle("Instantaneous");
String unit = null;
if (observationValue instanceof SingleObservationValue) {
SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
unit = singleObservationValue.getValue().getUnit();
if (observationValue.getValue() instanceof TimeLocationValueTriple) {
measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT((TimeLocationValueTriple) observationValue.getValue()));
}
} else if (observationValue instanceof MultiObservationValues) {
MultiObservationValues<?> multiObservationValue = (MultiObservationValues<?>) observationValue;
if (multiObservationValue.getValue() instanceof TLVTValue) {
TLVTValue tlvtValue = (TLVTValue) multiObservationValue.getValue();
List<TimeLocationValueTriple> timeLocationValueTriples = tlvtValue.getValue();
unit = tlvtValue.getUnit();
int counter = 0;
for (TimeLocationValueTriple timeLocationValueTriple : timeLocationValueTriples) {
timeLocationValueTriple.getLocation().setUserData(getUserObject(observationValue.getObservationID(), counter));
measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT(timeLocationValueTriple));
counter++;
}
}
}
if (unit != null && !unit.isEmpty()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
}
xbMetaComponent.set(xbDefMeasureMetaComponent);
return measurementTimeseriesDoc;
}
Aggregations