use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.
the class TrajectoryObservationTypeEncoderTest method getCountObservation.
private OmObservation getCountObservation() throws EncodingException, ParseException, DecodingException, XmlException, IOException {
MultiObservationValues<List<TimeLocationValueTriple>> multiObservationValues = new MultiObservationValues<List<TimeLocationValueTriple>>();
TLVTValue tlvtValue = new TLVTValue();
tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(15)));
tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(16)));
tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(17)));
tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(18)));
multiObservationValues.setValue(tlvtValue);
OmObservation observation = createObservation();
observation.setValue(multiObservationValues);
return observation;
}
use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.
the class TrajectoryObservation method mergeValues.
protected boolean mergeValues(ObservationValue<?> observationValue) {
if (observationValue.getValue() instanceof TLVTValue) {
TLVTValue tlvtValue = (TLVTValue) observationValue.getValue();
List<TimeLocationValueTriple> valuesToMerge = tlvtValue.getValue();
// List<TimeLocationValueTriple> valuesToMerge =
// (List<TimeLocationValueTriple>)((TLVTValue)observationValue.getValue()).getValue();
((TLVTValue) getValue().getValue()).addValues(valuesToMerge);
checkForFeature(valuesToMerge);
return true;
} else {
return super.mergeValues(observationValue);
}
}
use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.
the class TrajectoryObservation method checkForFeature.
/**
* Create geometry for featureOfInterest from
* {@link TimeLocationValueTriple}s
*
* @param values
* The {@link TimeLocationValueTriple}s to check for
* featureOfInterest
*/
private void checkForFeature(List<TimeLocationValueTriple> values) {
AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
Coordinate[] coords = getCoordinates(values);
int srid = 0;
if (sf.isSetGeometry()) {
srid = sf.getGeometry().getSRID();
coords = (Coordinate[]) ArrayUtils.addAll(sf.getGeometry().getCoordinates(), coords);
} else {
TimeLocationValueTriple next = values.iterator().next();
if (next.isSetLocation()) {
srid = next.getLocation().getSRID();
}
}
try {
if (coords.length == 1) {
Point point = new GeometryFactory().createPoint(coords[0]);
point.setSRID(srid);
sf.setGeometry(point);
} else if (coords.length > 1) {
LineString lineString = new GeometryFactory().createLineString(coords);
lineString.setSRID(srid);
sf.setGeometry(lineString);
}
} catch (InvalidSridException e) {
// TODO
}
}
}
use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.
the class AbstractTimeLocationValueTripleTypeEncoder method createMeasurementTimeLocationValueTripleType.
/**
* Create a {@link MeasurementTimeLocationValueTripleType} from
* {@link TimeLocationValueTriple}
*
* @param timeLocationValueTriple
* The {@link TimeLocationValueTriple} to encode
* @return The encoded {@link TimeLocationValueTriple}
* @throws EncodingException
* If an error occurs
*/
private TimeValuePairType createMeasurementTimeLocationValueTripleType(TimeLocationValueTriple timeLocationValueTriple) throws EncodingException {
MeasurementTimeLocationValueTripleType mtlvtt = MeasurementTimeLocationValueTripleType.Factory.newInstance();
mtlvtt.addNewTime().setStringValue(getTimeString(timeLocationValueTriple.getTime()));
mtlvtt.addNewLocation().addNewPoint().set(encodeGML(timeLocationValueTriple.getLocation()));
String value = null;
if (timeLocationValueTriple.getValue() instanceof QuantityValue) {
QuantityValue quantityValue = (QuantityValue) timeLocationValueTriple.getValue();
if (quantityValue.isSetValue()) {
value = quantityValue.getValue().toPlainString();
}
} else if (timeLocationValueTriple.getValue() instanceof CountValue) {
CountValue countValue = (CountValue) timeLocationValueTriple.getValue();
if (countValue.getValue() != null) {
value = Integer.toString(countValue.getValue().intValue());
}
}
if (value != null && !value.isEmpty()) {
mtlvtt.addNewValue().setStringValue(value);
} else {
mtlvtt.addNewValue().setNil();
mtlvtt.addNewMetadata().addNewTVPMeasurementMetadata().addNewNilReason().setNilReason(MISSING);
}
return mtlvtt;
}
use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.
the class AbstractTimeLocationValueTripleTypeEncoder method createCategoricalTimeLocationValueTripleType.
/**
* Create a {@link CategoricalTimeLocationValueTripleType} from
* {@link TimeLocationValueTriple}
*
* @param timeLocationValueTriple
* The {@link TimeLocationValueTriple} to encode
* @return The encoded {@link TimeLocationValueTriple}
* @throws EncodingException
* If an error occurs
*/
private TimeValuePairType createCategoricalTimeLocationValueTripleType(TimeLocationValueTriple timeLocationValueTriple) throws EncodingException {
CategoricalTimeLocationValueTripleType ctlvtt = CategoricalTimeLocationValueTripleType.Factory.newInstance();
ctlvtt.addNewTime().setStringValue(getTimeString(timeLocationValueTriple.getTime()));
ctlvtt.addNewLocation().addNewPoint().set(encodeGML(timeLocationValueTriple.getLocation()));
if (timeLocationValueTriple.getValue() instanceof CategoryValue) {
CategoryValue categoryValue = (CategoryValue) timeLocationValueTriple.getValue();
if (categoryValue.isSetValue()) {
ctlvtt.addNewValue().addNewCategory().set(encodeSweCommon(convertToSweCategory(categoryValue)));
} else {
ctlvtt.addNewValue().setNil();
ctlvtt.addNewMetadata().addNewTVPMetadata().addNewNilReason().setNilReason(MISSING);
}
}
return ctlvtt;
}
Aggregations