use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class WmlObservationProcessDecoderv20 method parseObservationProcess.
private Object parseObservationProcess(ObservationProcessType opt) throws DecodingException {
ObservationProcess observationProcess = new ObservationProcess();
observationProcess.setGmlId(opt.getId());
// parse identifier, names, description, locations
parseAbstractFeatureType(opt, observationProcess);
parseProcessType(opt, observationProcess);
parseOriginatingProcess(opt, observationProcess);
parseAggregatingDuration(opt, observationProcess);
parseVerticalDatum(opt, observationProcess);
parseComment(opt, observationProcess);
parseProcessReference(opt, observationProcess);
parseInput(opt, observationProcess);
parseParameter(opt, observationProcess);
setDescriptionXml(opt, observationProcess);
return observationProcess;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class OmDecoderv20 method getResult.
private ObservationValue<?> getResult(OMObservationType omObservation) throws DecodingException {
XmlObject xbResult = omObservation.getResult();
if (xbResult.schemaType() == XmlAnyTypeImpl.type) {
// Template observation for InsertResultTemplate operation
if (!xbResult.getDomNode().hasChildNodes()) {
return new SingleObservationValue<>(new NilTemplateValue());
} else {
try {
xbResult = XmlObject.Factory.parse(xbResult.xmlText().trim());
} catch (XmlException e) {
LOGGER.error("Error while parsing NamedValueValue", e);
}
}
}
if (xbResult.schemaType() == XmlBoolean.type) {
// TruthObservation
XmlBoolean xbBoolean = (XmlBoolean) xbResult;
BooleanValue booleanValue = new BooleanValue(xbBoolean.getBooleanValue());
return new SingleObservationValue<>(booleanValue);
} else if (xbResult.schemaType() == XmlInteger.type) {
// CountObservation
XmlInteger xbInteger = (XmlInteger) xbResult;
CountValue countValue = new CountValue(Integer.parseInt(xbInteger.getBigIntegerValue().toString()));
return new SingleObservationValue<>(countValue);
} else if (xbResult.schemaType() == XmlString.type) {
// TextObservation
XmlString xbString = (XmlString) xbResult;
TextValue stringValue = new TextValue(xbString.getStringValue());
return new SingleObservationValue<>(stringValue);
} else {
// result elements with other encoding like SWE_ARRAY_OBSERVATION
Object decodedObject = decodeXmlObject(xbResult);
if (decodedObject instanceof ObservationValue) {
return (ObservationValue<?>) decodedObject;
} else if (decodedObject instanceof GmlMeasureType) {
GmlMeasureType measureType = (GmlMeasureType) decodedObject;
QuantityValue quantitiyValue = new QuantityValue(measureType.getValue(), measureType.getUnit());
return new SingleObservationValue<>(quantitiyValue);
} else if (decodedObject instanceof ReferenceType) {
if (omObservation.isSetType() && omObservation.getType().isSetHref() && omObservation.getType().getHref().equals(OmConstants.OBS_TYPE_REFERENCE_OBSERVATION)) {
return new SingleObservationValue<>(new ReferenceValue((ReferenceType) decodedObject));
}
return new SingleObservationValue<>(new CategoryValue(((ReferenceType) decodedObject).getHref()));
} else if (decodedObject instanceof Geometry) {
return new SingleObservationValue<>(new GeometryValue((Geometry) decodedObject));
} else if (decodedObject instanceof AbstractGeometry) {
SingleObservationValue<Geometry> result = new SingleObservationValue<>();
result.setValue(new GeometryValue(((AbstractGeometry) decodedObject).getGeometry()));
return result;
} else if (decodedObject instanceof SweDataArray) {
return new SingleObservationValue<>(new SweDataArrayValue((SweDataArray) decodedObject));
} else if (decodedObject instanceof SweDataRecord) {
return new SingleObservationValue<>(new ComplexValue((SweDataRecord) decodedObject));
}
throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested result type '{}' is not supported by this service!", decodedObject.getClass().getSimpleName());
}
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class OmDecoderv20 method getObservationConstellation.
private OmObservationConstellation getObservationConstellation(OMObservationType omot, Map<String, AbstractFeature> featureMap) throws DecodingException {
OmObservationConstellation observationConstellation = new OmObservationConstellation();
observationConstellation.setObservationType(getObservationType(omot));
observationConstellation.setProcedure(createProcedure(omot));
observationConstellation.setObservableProperty(getObservableProperty(omot));
observationConstellation.setFeatureOfInterest(createFeatureOfInterest(omot, featureMap));
return observationConstellation;
}
use of org.n52.svalbard.decode.exception.DecodingException 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 org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class OmDecoderv20 method parseOmObservation.
private OmObservation parseOmObservation(OMObservationType omObservation) throws DecodingException {
Map<String, AbstractFeature> featureMap = Maps.newHashMap();
OmObservation sosObservation = new OmObservation();
// parse identifier, description
parseAbstractFeatureType(omObservation, sosObservation);
OmObservationConstellation observationConstallation = getObservationConstellation(omObservation, featureMap);
sosObservation.setObservationConstellation(observationConstallation);
sosObservation.setResultTime(getResultTime(omObservation));
sosObservation.setValidTime(getValidTime(omObservation));
if (omObservation.getParameterArray() != null) {
sosObservation.setParameter(parseNamedValueTypeArray(omObservation.getParameterArray()));
}
sosObservation.setValue(getObservationValue(omObservation));
return sosObservation;
}
Aggregations