Alexander Thomson Orr, Royal Engineers