ConvertLatLon { public static double extractDouble(NodeValue nodeValue){ if (nodeValue.isNumber()) { return nodeValue.getDouble(); } else if (nodeValue.isString()) { try { return Double.parseDouble(nodeValue.getString()); } catch (NumberFormatException e) { } } throw new DatatypeFormatException("Not a number: " + FmtUtils.stringForNode(nodeValue.asNode())); }  static final Literal toLiteral(double lat, double lon); static final String toWKT(double lat, double lon); static final NodeValue toNodeValue(NodeValue latNodeValue, NodeValue lonNodeValue); static double extractDouble(NodeValue nodeValue); static final Node toNode(Node latNode, Node lonNode); static final GeometryWrapper toGeometryWrapper(Node latNode, Node lonNode); static final void checkBounds(double latitude, double longitude);  }
@Test public void testExtractDouble() { NodeValue nv = NodeValue.makeDouble(10.0); double result = extractDouble(nv); assertEquals(10.0, result, 0); }
@Test public void testExtractDouble_String() { NodeValue nv = NodeValue.makeString("10.0"); double result = extractDouble(nv); assertEquals(10.0, result, 0); }
@Test(expected = DatatypeFormatException.class) public void testExtractDouble_Malformed() { NodeValue nv = NodeValue.makeString("val"); extractDouble(nv); }