if (i < positions.size() - 1)
waypointsBuffer.append(",");
}
}
BoundingBox boundingBox = new BoundingBox(positions);
String southWestBuffer = "new google.maps.LatLng(" + boundingBox.getSouthWest().getLatitude() + "," + boundingBox.getSouthWest().getLongitude() + ")";
String northEastBuffer = "new google.maps.LatLng(" + boundingBox.getNorthEast().getLatitude() + "," + boundingBox.getNorthEast().getLongitude() + ")";
String centerBuffer = "new google.maps.LatLng(" + boundingBox.getCenter().getLatitude() + "," + boundingBox.getCenter().getLongitude() + ")";
String output = template.replaceAll("INSERT_ROUTENAME", route.getName()).
replaceAll("INSERT_TRACK", routeBuffer.toString()).
replaceAll("INSERT_ROUTE", trackBuffer.toString()).
replaceAll("INSERT_WAYPOINTS", waypointsBuffer.toString()).