本文整理汇总了Java中net.opengis.swe.x101.QuantityDocument类的典型用法代码示例。如果您正苦于以下问题:Java QuantityDocument类的具体用法?Java QuantityDocument怎么用?Java QuantityDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QuantityDocument类属于net.opengis.swe.x101包,在下文中一共展示了QuantityDocument类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setNamedCoordinate
import net.opengis.swe.x101.QuantityDocument; //导入依赖的package包/类
private void setNamedCoordinate(double value, String name, VectorType vector) {
QuantityDocument quantityDoc = QuantityDocument.Factory.newInstance();
Quantity quantity = quantityDoc.addNewQuantity();
quantity.setValue(value);
Coordinate coordiante = vector.addNewCoordinate();
coordiante.setQuantity(quantity);
coordiante.setName(name);
}
示例2: createQuantity
import net.opengis.swe.x101.QuantityDocument; //导入依赖的package包/类
protected QuantityDocument createQuantity(RuleFilter ruleFilter) {
QuantityDocument quantityDoc = QuantityDocument.Factory.newInstance();
Quantity quantity = quantityDoc.addNewQuantity();
quantity.setValue(Double.parseDouble(ruleFilter.getValue()));
if (isValidUom(ruleFilter.getUnit())) {
quantity.addNewUom().setCode(ruleFilter.getUnit());
}
return quantityDoc;
}
示例3: replaceForExpression
import net.opengis.swe.x101.QuantityDocument; //导入依赖的package包/类
/**
* helpermethod for replacePhenomenonStringsAndConvertUnits().
* @throws Exception
*/
public static void replaceForExpression(XmlObject et) throws Exception {
QName etQn = et.newCursor().getName();
if (et instanceof LiteralType) {
LiteralType lt = (LiteralType) et;
XmlObject xmlContent = XmlObject.Factory.parse(lt.toString());
if (xmlContent instanceof QuantityDocument) {
QuantityDocument sweQ = (QuantityDocument) xmlContent;
if (sweQ.getQuantity() != null) {
if (!sweQ.getQuantity().isSetValue()) {
throw new Exception("There was" +
" no Value specified in the swe:Quantity element");
}
Double value = sweQ.getQuantity().getValue();
UomPropertyType uom = sweQ.getQuantity().getUom();
String uomCode = "";
if (uom != null) {
uomCode = uom.getCode();
}
else {
//no ucum-code, just return without converting
return;
}
try {
NumberWithUOM result = UCUMTools.convert(uomCode, value);
sweQ.getQuantity().setValue(result.getValue());
sweQ.getQuantity().getUom().setCode(result.getUom());
et.set(sweQ);
}
catch (Exception t) {
logger.warn("Could not convert uom '" + uom.xmlText(new XmlOptions().setSaveOuter()) +
"' to base unit, reason: " + t.getMessage());
if (t instanceof RuntimeException) throw (RuntimeException) t;
throw new RuntimeException(t);
}
}
}
}
else if (VALUE_REFERENCE_QNAME.equals(etQn)) {
String urn = XmlUtil.stripText(et);
urn = urn.replaceAll(":", "__").replaceAll("\\.", "_");
XmlUtil.setTextContent(et, urn);
}
}
示例4: replaceForExpression
import net.opengis.swe.x101.QuantityDocument; //导入依赖的package包/类
/**
* helpermethod for replacePhenomenonStringsAndConvertUnits().
* @throws Exception
*/
public static void replaceForExpression(XmlObject et, IUnitConverter converter) throws Exception {
QName etQn = et.newCursor().getName();
if (et instanceof LiteralType) {
LiteralType lt = (LiteralType) et;
XmlObject xmlContent = XmlObject.Factory.parse(lt.toString());
if (xmlContent instanceof QuantityDocument) {
QuantityDocument sweQ = (QuantityDocument) xmlContent;
if (sweQ.getQuantity() != null) {
if (!sweQ.getQuantity().isSetValue()) {
throw new SubscribeCreationFailedFault("There was" +
" no Value specified in the swe:Quantity element");
}
Double value = sweQ.getQuantity().getValue();
UomPropertyType uom = sweQ.getQuantity().getUom();
String uomCode = "";
if (uom != null) {
uomCode = uom.getCode();
}
else {
//no ucum-code, just return without converting
return;
}
try {
NumberWithUOM result = converter.convert(uomCode, value);
sweQ.getQuantity().setValue(result.getValue());
sweQ.getQuantity().getUom().setCode(result.getUom());
et.set(sweQ);
}
catch (Throwable t) {
logger.warn("Could not convert uom '" + uom.xmlText(new XmlOptions().setSaveOuter()) +
"' to base unit, reason: " + t.getMessage());
if (t instanceof RuntimeException) throw (RuntimeException) t;
throw new RuntimeException(t);
}
}
}
}
else if (VALUE_REFERENCE_QNAME.equals(etQn)) {
Element elem = (Element) et.getDomNode();
String urn = XmlUtils.toString(elem.getFirstChild()).trim();
urn = urn.replaceAll(":", "__").replaceAll("\\.", "_");
XmlUtils.setElementText(elem, urn);
}
}
示例5: getQuantityFrom
import net.opengis.swe.x101.QuantityDocument; //导入依赖的package包/类
private Quantity getQuantityFrom(BinaryComparisonOpType comparisonType) throws XmlException {
Node literalNode = getXmlAnyNodeFrom(comparisonType, "Literal").getDomNode();
LiteralDocument literal = LiteralDocument.Factory.parse(literalNode);
return ((QuantityDocument) getXmlAnyNodeFrom(literal.getLiteral(), "Quantity")).getQuantity();
}