use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class TrajectoryObservation method cloneTemplate.
@Override
public OmObservation cloneTemplate() {
SamplingFeature sf = new SamplingFeature(new CodeWithAuthority(""));
sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
getObservationConstellation().setFeatureOfInterest(sf);
if (isSetSpatialFilteringProfileParameter()) {
removeSpatialFilteringProfileParameter();
}
return cloneTemplate(new TrajectoryObservation());
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class OmObservation method mergeValues.
private void mergeValues(OmObservation merged, OmObservation observation) {
SweDataArray combinedValue = (SweDataArray) merged.getValue().getValue().getValue();
SweDataArray v = (SweDataArray) observation.getValue().getValue().getValue();
if (v.isSetValues()) {
combinedValue.addAll(v.getValues());
}
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class OmDecoderv20 method getResultTime.
private TimeInstant getResultTime(OMObservationType omObservation) throws DecodingException {
if (omObservation.getResultTime().isSetHref()) {
TimeInstant timeInstant = new TimeInstant();
timeInstant.setGmlId(omObservation.getResultTime().getHref());
if (omObservation.getResultTime().getHref().charAt(0) == '#') {
// document internal link
// TODO parse linked element
timeInstant.setReference(Sos2Constants.EN_PHENOMENON_TIME);
} else {
timeInstant.setReference(omObservation.getResultTime().getHref());
}
return timeInstant;
} else if (omObservation.getResultTime().isSetNilReason() && omObservation.getResultTime().getNilReason() instanceof String && NilReason.template.equals(NilReason.getEnumForString((String) omObservation.getResultTime().getNilReason()))) {
TimeInstant timeInstant = new TimeInstant();
timeInstant.setNilReason(NilReason.getEnumForString((String) omObservation.getResultTime().getNilReason()));
return timeInstant;
} else if (omObservation.getResultTime().isSetTimeInstant()) {
Object decodedObject = decodeXmlObject(omObservation.getResultTime().getTimeInstant());
if (decodedObject instanceof TimeInstant) {
return (TimeInstant) decodedObject;
}
throw unsupportedResultTimeType();
} else {
throw unsupportedResultTimeType();
}
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class OmDecoderv20 method getObservationValue.
private ObservationValue<?> getObservationValue(OMObservationType omObservation) throws DecodingException {
Time phenomenonTime = getPhenomenonTime(omObservation);
ObservationValue<?> observationValue;
if (!omObservation.getResult().getDomNode().hasChildNodes() && phenomenonTime.isSetNilReason() && phenomenonTime.getNilReason().equals(NilReason.template)) {
observationValue = new SingleObservationValue<>(new NilTemplateValue());
} else {
observationValue = getResult(omObservation);
}
observationValue.setPhenomenonTime(phenomenonTime);
return observationValue;
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method createWmlGetObservationResponse.
/**
* Encodes a SOS GetObservationResponse to a single WaterML 2.0 observation
* or to a WaterML 1.0 ObservationCollection
*
* @param getObservationResonse
* SOS GetObservationResponse
* @return Encoded response
* @throws EncodingException
* If an error occurs
*/
protected XmlObject createWmlGetObservationResponse(GetObservationResponse getObservationResonse) throws EncodingException {
// TODO: set schemaLocation if final
Map<CodeWithAuthority, String> gmlID4sfIdentifier = Maps.newHashMap();
int sfIdCounter = 1;
try {
if (getObservationResonse.getObservationCollection() != null && !getObservationResonse.getObservationCollection().hasNext()) {
ObservationStream observations = getObservationResonse.getObservationCollection();
OmObservation observation = observations.next();
if (!observations.hasNext()) {
OMObservationDocument omObservationDoc = OMObservationDocument.Factory.newInstance(getXmlOptions());
omObservationDoc.setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
return omObservationDoc;
} else {
CollectionDocument xmlCollectionDoc = CollectionDocument.Factory.newInstance(getXmlOptions());
CollectionType wmlCollection = xmlCollectionDoc.addNewCollection();
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
while (observations.hasNext()) {
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observations.next(), gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
}
return xmlCollectionDoc;
}
} else {
// TODO: HydrologieProfile-Exception
throw new EncodingException("Combination does not exists!");
}
} catch (NoSuchElementException | OwsExceptionReport e) {
throw new EncodingException(e);
}
}
Aggregations