use of org.n52.shetland.ogc.gml.GmlMeasureType 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.shetland.ogc.gml.GmlMeasureType in project arctic-sea by 52North.
the class AbstractGmlDecoderv321 method parseNamedValueValue.
protected NamedValue<?> parseNamedValueValue(XmlObject xml) throws DecodingException {
XmlObject xmlObject = xml;
if (xmlObject.schemaType() == XmlAnyTypeImpl.type) {
try {
xmlObject = XmlObject.Factory.parse(xml.xmlText().trim());
} catch (XmlException e) {
LOGGER.error("Error while parsing NamedValueValue", e);
}
}
Object value;
if (XmlBoolean.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
value = ((XmlBoolean) xmlObject).getBooleanValue();
} else if (XmlString.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
value = ((XmlString) xmlObject).getStringValue();
} else if (XmlInt.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
value = ((XmlInt) xmlObject).getIntValue();
} else if (XmlInteger.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
value = ((XmlInteger) xmlObject).getBigIntegerValue().intValue();
} else if (XmlDouble.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
value = ((XmlDouble) xmlObject).getDoubleValue();
} else {
value = decodeXmlObject(xmlObject);
}
if (value instanceof BooleanValue) {
NamedValue<Boolean> namedValue = new NamedValue<>();
namedValue.setValue((BooleanValue) value);
return namedValue;
} else if (value instanceof SweBoolean) {
NamedValue<Boolean> namedValue = new NamedValue<>();
namedValue.setValue(new BooleanValue(((SweBoolean) value).getValue()));
return namedValue;
} else if (value instanceof Boolean) {
NamedValue<Boolean> namedValue = new NamedValue<>();
namedValue.setValue(new BooleanValue((Boolean) value));
return namedValue;
} else if (value instanceof CategoryValue) {
NamedValue<String> namedValue = new NamedValue<>();
namedValue.setValue((CategoryValue) value);
return namedValue;
} else if (value instanceof SweCategory) {
NamedValue<String> namedValue = new NamedValue<>();
namedValue.setValue(new CategoryValue(((SweCategory) value).getValue(), ((SweCategory) value).getCodeSpace()));
return namedValue;
} else if (value instanceof CountValue) {
NamedValue<Integer> namedValue = new NamedValue<>();
namedValue.setValue((CountValue) value);
return namedValue;
} else if (value instanceof SweCount) {
NamedValue<Integer> namedValue = new NamedValue<>();
namedValue.setValue(new CountValue(((SweCount) value).getValue()));
return namedValue;
} else if (value instanceof Integer) {
NamedValue<Integer> namedValue = new NamedValue<>();
namedValue.setValue(new CountValue((Integer) value));
return namedValue;
} else if (value instanceof GeometryValue) {
NamedValue<Geometry> namedValue = new NamedValue<>();
namedValue.setValue((GeometryValue) value);
return namedValue;
} else if (value instanceof QuantityValue) {
NamedValue<BigDecimal> namedValue = new NamedValue<>();
namedValue.setValue((QuantityValue) value);
return namedValue;
} else if (value instanceof GmlMeasureType) {
NamedValue<BigDecimal> namedValue = new NamedValue<>();
namedValue.setValue(new QuantityValue(((GmlMeasureType) value).getValue(), ((GmlMeasureType) value).getUnit()));
return namedValue;
} else if (value instanceof SweQuantity) {
NamedValue<BigDecimal> namedValue = new NamedValue<>();
namedValue.setValue(new QuantityValue(((SweQuantity) value).getValue(), ((SweQuantity) value).getUom()));
return namedValue;
} else if (value instanceof Double) {
NamedValue<BigDecimal> namedValue = new NamedValue<>();
namedValue.setValue(new QuantityValue((Double) value));
return namedValue;
} else if (value instanceof TextValue) {
NamedValue<String> namedValue = new NamedValue<>();
namedValue.setValue((TextValue) value);
return namedValue;
} else if (value instanceof SweText) {
NamedValue<String> namedValue = new NamedValue<>();
namedValue.setValue(new TextValue(((SweText) value).getValue()));
return namedValue;
} else if (value instanceof String) {
NamedValue<String> namedValue = new NamedValue<>();
namedValue.setValue(new TextValue((String) value));
return namedValue;
} else if (value instanceof AbstractGeometry) {
NamedValue<Geometry> namedValue = new NamedValue<>();
namedValue.setValue(new GeometryValue((AbstractGeometry) value));
return namedValue;
} else if (value instanceof org.n52.shetland.ogc.gml.ReferenceType) {
NamedValue<org.n52.shetland.ogc.gml.ReferenceType> namedValue = new NamedValue<>();
namedValue.setValue(new ReferenceValue((org.n52.shetland.ogc.gml.ReferenceType) value));
return namedValue;
} else if (value instanceof W3CHrefAttribute) {
NamedValue<W3CHrefAttribute> namedValue = new NamedValue<>();
namedValue.setValue(new HrefAttributeValue((W3CHrefAttribute) value));
return namedValue;
} else {
throw new UnsupportedDecoderInputException(this, xmlObject);
}
}
use of org.n52.shetland.ogc.gml.GmlMeasureType in project arctic-sea by 52North.
the class GmlDecoderv321 method parseMeasureType.
private GmlMeasureType parseMeasureType(MeasureType measureType) {
GmlMeasureType sosMeasureType = new GmlMeasureType(measureType.getDoubleValue());
sosMeasureType.setUnit(measureType.getUom());
return sosMeasureType;
}
Aggregations