private void write(Coordinate[] coords,int level,StringBuffer buf){
  startLine("<coordinates>",level,buf);
  boolean isNewLine=false;
  for (int i=0; i < coords.length; i++) {
    if (i > 0) {
      buf.append(TUPLE_SEPARATOR);
    }
    if (isNewLine) {
      startLine("  ",level,buf);
      isNewLine=false;
    }
    write(coords[i],buf);
    if ((i + 1) % maxCoordinatesPerLine == 0 && i < coords.length - 1) {
      buf.append("\n");
      isNewLine=true;
    }
  }
  buf.append("</coordinates>\n");
}

private void write ( Coordinate [ ] coords , int level , StringBuffer buf ) { startLine ( "<coordinates>" , level , buf ) ; boolean isNewLine = false ; for ( int i = 0 ; i < coords . length ; i ++ ) { if ( i > 0 ) { buf . append ( TUPLE_SEPARATOR ) ; } if ( isNewLine ) { startLine ( "  " , level , buf ) ; isNewLine = false ; } write ( coords [ i ] , buf ) ; if ( ( i + 1 ) % maxCoordinatesPerLine == 0 && i < coords . length - 1 ) { buf . append ( "\n" ) ; isNewLine = true ; } } buf . append ( "</coordinates>\n" ) ; }
takes a list of coordinates and converts it to kml . < br > 2d and 3d aware . terminates the coordinate output with a newline .
