/** * Formats a number with the configured number of decimals. For better performance best use * {@link #format(double, StringBuffer)} against a re-used StringBuffer * * @param x * @param sb */ public String format(double x) { StringBuffer sb = new StringBuffer(); format(x, sb); return sb.toString(); }
private void formatAndAppend(StringBuffer sb, double v) { // separator char is a blank if (formatter != null) { formatter.format(v, sb); } else { sb.append(String.valueOf(v)); } sb.append(" "); } }
/** * Writes a single ordinate, without wrapping it inside any element * * @param x * @throws SAXException */ public void ordinate(double x) throws SAXException { sb.setLength(0); coordFormatter.format(x, sb); characters(sb); }
void coordinates(CoordinateSequence coordinates, char cs, char ts, StringBuffer sb) { sb.setLength(0); int n = coordinates.size(); int dim = CoordinateSequences.coordinateDimension(coordinates); for (int i = 0; i < n; i++) { coordFormatter.format(coordinates.getX(i), sb).append(cs); coordFormatter.format(coordinates.getY(i), sb); if (dim > 2) { int totalDimensions = encodeMeasures ? dim : dim - coordinates.getMeasures(); // encoding the remaining ordinates, typically Z and M values for (int j = 2; j < totalDimensions; j++) { sb.append(cs); coordFormatter.format(coordinates.getOrdinate(i, j), sb); } } sb.append(ts); } sb.setLength(sb.length() - 1); }
double ordinate = cs.getOrdinate(i, d); if (formatter != null) { formatter.format(ordinate, sb); } else { sb.append(ordinate);