use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.
the class OmDecoderv20 method getPhenomenonTime.
private Time getPhenomenonTime(OMObservationType omObservation) throws DecodingException {
TimeObjectPropertyType phenomenonTime = omObservation.getPhenomenonTime();
if (phenomenonTime.isSetHref() && phenomenonTime.getHref().startsWith("#")) {
TimeInstant timeInstant = new TimeInstant();
timeInstant.setGmlId(phenomenonTime.getHref());
return timeInstant;
} else if (phenomenonTime.isSetNilReason() && phenomenonTime.getNilReason() instanceof String && ((String) phenomenonTime.getNilReason()).equals(IndeterminateValue.TEMPLATE.getValue())) {
return new TimeInstant(IndeterminateValue.TEMPLATE);
} else if (phenomenonTime.isSetAbstractTimeObject()) {
Object decodedObject = decodeXmlObject(phenomenonTime.getAbstractTimeObject());
if (decodedObject instanceof Time) {
return (Time) decodedObject;
}
// FIXME else
}
throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested phenomenonTime type is not supported by this service!");
}
use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method encodeOmObservation.
/**
* Method to create an O&M 2.0 observation XmlBeans object
*
* @param sosObservation
* SosObservation to be encoded
* @param context
* Additional values which are used during the encoding
* @return XmlBeans representation of O&M 2.0 observation
* @throws EncodingException
* If an error occurs
*/
protected XmlObject encodeOmObservation(OmObservation sosObservation, EncodingContext context) throws EncodingException {
OMObservationType xbObservation = createOmObservationType();
if (!sosObservation.isSetObservationID()) {
sosObservation.setObservationID(JavaHelper.generateID(Double.toString(System.currentTimeMillis() * Math.random())));
}
String observationID = sosObservation.getObservationID();
if (!sosObservation.isSetGmlID()) {
sosObservation.setGmlId(OBSERVATION_ID_PREFIX + observationID);
}
// set a unique gml:id
xbObservation.setId(generateObservationGMLId());
if (!sosObservation.isSetObservationID()) {
sosObservation.setObservationID(xbObservation.getId().replace(OBSERVATION_ID_PREFIX, ""));
}
setObservationIdentifier(sosObservation, xbObservation);
setObservationName(sosObservation, xbObservation);
setDescription(sosObservation, xbObservation);
setMetaDataProperty(sosObservation, xbObservation);
setObservationType(sosObservation, xbObservation);
setRelatedObservations(sosObservation, xbObservation);
setPhenomenonTime(sosObservation, xbObservation);
setResultTime(sosObservation, xbObservation);
setValidTime(sosObservation, xbObservation);
setProcedure(sosObservation, xbObservation);
setParameter(sosObservation, xbObservation);
setObservableProperty(sosObservation, xbObservation);
setFeatureOfInterest(sosObservation, xbObservation);
setResultQualities(xbObservation, sosObservation);
setResult(sosObservation, xbObservation);
addAddtitionalInformation(xbObservation, sosObservation);
if (context.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
return createObservationPropertyType(xbObservation);
} else if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
return createObservationDocument(xbObservation);
} else {
return xbObservation;
}
}
use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method createObservationDocument.
private XmlObject createObservationDocument(OMObservationType xbObservation) {
OMObservationDocument doc = createObservationDocument();
doc.setOMObservation(xbObservation);
return doc;
}
use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method createObservationPropertyType.
private XmlObject createObservationPropertyType(OMObservationType obs) {
OMObservationPropertyType opt = createObservationPropertyType();
opt.setOMObservation(obs);
return opt;
}
use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.
the class OmEncoderv20 method addProcedure.
private void addProcedure(OMObservationType xbObservationTemplate, Nillable<AbstractFeature> procedure) {
OMProcessPropertyType xbProcedure = xbObservationTemplate.addNewProcedure();
if (procedure.isNil() || procedure.isAbsent() || !procedure.get().isSetIdentifier()) {
xbProcedure.setNil();
xbProcedure.setNilReason(NIL_REASON_TEMPLATE);
} else {
xbProcedure.setHref(procedure.get().getIdentifier());
}
}
Aggregations